AngularJS函数未调用

时间:2014-03-30 23:36:11

标签: javascript html angularjs

这是一个简单的角度控制器,但不起作用。我无法找到代码的任何问题。你能 ?

<!DOCTYPE html>
<html>
<head>
<title>AngularJS Controller</title>
</head>
<body>
    <div ng-controller="SimpleController">
        Name:
        <br/>
        <input type="text" ng-model="nameText"/>
        <br/>
        <ul>
        <li ng-repeat="cust in customers | filter:nameText | orderBy : 'name' ">{{ cust.name }} - {{ cust.city }}
        </li>
        </ul>
    </div>


<script src="Scripts/angular.min.js"></script>

<script>
    function SimpleController ($scope){
        $scope.customers = [ 
            { name:'Konstantinos Korovesis', city:'Pikermi' },
            { name:'Akis Manolis', city:'Argos' },
            { name:'Irem Var', city:'Nea Smirni' },
            { name:'Antonis Ralis', city:'Pallini' }
        ];
    }
</script>

</body>
</html>

.................................这就是我在浏览器中看到的...... .............

名称:

[................]

{{cust.name}} - {{cust.city}}

1 个答案:

答案 0 :(得分:1)

添加ng-app。 Angular需要它来为angular指定文档的根目录。

<html ng-app>