AngularJS 应用
AngularJS 模块(Module) 定义了 AngularJS 应用。
AngularJS 控制器(Controller) 用于控制 AngularJS 应用。
ng-app指令定义了应用, ng-controller 定义了控制器。
------html-----
<html ng-app="test" ng-controller='ctr' >
<head>
<meta charset="utf-8">
<script type="text/javascript" src="js/angular.min.js">
</script>
<script type="text/javascript" src="js/module.js">
</script>
</head>
<body >
<input type="text" ng-model="firstName" />
姓名是{{firstName}}
</div>
</body>
---js---
var app=angular.module('test',[]);
app.controller("ctr",function($scope){ //%scope是ng应用的作用域
$scope.firstName='haha';
});
---问题---当将ng-controller放在<input type="text" ng-controller='ctr' ng-model="firstName" />的时候。只能在input输入框里面显示初始值,而表达式则无法显示。这个指令的位置产生这种现象是因为其执行顺序导致的还是?