适用于Angular 1.2,但不适用于1.3

时间:2014-10-22 15:21:41

标签: angularjs

以下小角色应用程序使用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>

数据绑定似乎不起作用...... 为什么?有什么建议吗?

1 个答案:

答案 0 :(得分:-1)

在AngularJS 1.3版本中,您无法再使用内联语法声明全局函数,例如:

angular.module('yourApp',[]).controller('MyController', ['$scope', function($scope){

}])