以下小角色应用程序使用1.2.26而不是1.3.0。
<!DOCTYPE html>
<html>
<head>
<!--<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js"></script>-->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js"></script>
<script>
function MyController() {
this.data = {
txtHello: "Hello"
};
}
</script>
</head>
<body ng-app ng-controller="MyController as controller">
<p><input ng-model="controller.data.txtHello"></p>
<p>Text: {{controller.data.txtHello}}</p>
</body>
</html>
数据绑定似乎不起作用...... 为什么?有什么建议吗?
答案 0 :(得分:-1)
在AngularJS 1.3版本中,您无法再使用内联语法声明全局函数,例如:
angular.module('yourApp',[]).controller('MyController', ['$scope', function($scope){
}])