<!DOCTYPE html>
<html lang="ja" ng-app="testx">
<head>
<meta charset="UTF-8">
<title>Angular</title>
<script src="angular.js"></script>
<script src="sample.js"></script>
</head>
<body>
<div class="test1" ng-controller="t1 as appx">
<h1>{{appx.message}}</h1>
<button ng-click="appx.hello('B')">C</button>
</div>
<div class="test2" ng-controller="t2 as appx">
<h1>{{appx.message}}</h1>
<button ng-click="appx.hel('BBBB')">C</button>
</div>
</body>
</html>
var appx = angular.module("testx", []);
appx.controller('t1', function(){
this.message = "猫";
this.hello = function(string) {
this.message ="AAA"+string;
};
});
appx.controller('t2', function(){
this.message = "犬";
this.hel = function(string){
this.message="CCCC"+string;
};
});
最終更新:2015年04月24日 05:11