首页 > 代码库 > angularjs中ng-controller中绑定对象

angularjs中ng-controller中绑定对象

<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.red{ background:red;}
.yellow{ background:yellow;}
</style>
<script src="http://www.mamicode.com/angular.min.js"></script>
<script>

/*var m1 = angular.module(‘myApp‘,[]);
m1.controller(‘Aaa‘,[‘$scope‘,function($scope){
$scope.text = ‘hello‘;

}]);*/

var m1 = angular.module(‘myApp‘,[]);
m1.controller(‘Aaa‘,[‘$scope‘,FnAaa]);

function FnAaa($scope){
}
FnAaa.prototype.num = ‘123‘;
FnAaa.prototype.text = ‘hello‘;
FnAaa.prototype.show = function(){
return ‘angularJS‘;
};

</script>
</head>

<body>
<!--<div ng-controller="Aaa">
<input type="text" ng-model="text" ng-model-options="{updateOn : ‘blur‘}">
<div>{{text}}</div>
</div>-->
<div ng-controller="FnAaa as a1">
<div>{{a1.text}}:{{a1.show()}}</div>
</div>
</body>
</html>

angularjs中ng-controller中绑定对象