<!DOCTYPE html>
<html lang="en" ng-app="testApp">
<head>
<meta charset="UTF-8">
<title>Angular Get Started</title>
<body>
<div class="test1" ng-controller="testAppController1 as app">
<h1>{{app.message}}</h1>
<button ng-click="app.hello('App1')">Click Me</button>
</div>
<div class="test2" ng-controller="testAppController2 as app">
<h1>{{app.message}}</h1>
<button ng-click="app.hello('App2')">Click Me</button>
</div>
<script src="angular.js"></script>
<script src="sample.js"></script>
</body>
</html>
var app = angular.module("testApp", []);
/**
* controllerでアプリケーションの機能を設定する
*/
app.controller('testAppController1', function(){
this.message = "First App 1";
this.hello = function(string) {
alert('Hello ' + string);
};
});
app.controller('testAppController2', function(){
this.message = "First App 2";
this.hello = function(string){
alert('Hello ' + string);
};
});
最終更新:2015年04月23日 18:44