<!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')">Click</button>
</div>
<div class="test2" ng-controller="t2 as appx">
<h1>{{appx.message}}</h1>
<button ng-click="appx.hello('A')">Click</button>
</div>
</body>
</html>
var appx = angular.module("testx", []);
appx.controller('t1', function(){
this.message = "猫";
this.hello = function(string) {
this.message = string;
};
});
appx.controller('t2', function(){
this.message = "犬";
this.hello = function(string){
this.message="J"+string;
};
});
最終更新:2015年04月24日 05:02