为什么得到错误“Undefined function”AngularJS

时间:2015-09-27 10:27:55

标签: angularjs

我想从数组中过滤结果,但我收到错误“SimpleController不是函数,未定义”

<div class="container" ng-controller="SimpleController">
    <input type="text" ng-model="name">
    <ul>
        <li ng-repeat="PersonNames in names | filter:name | orderBy:name">{{ PersonNames.name }} - {{PersonNames.city}}</li>
    </ul>
</div>

JS

  <script>
   function SimpleController($scope){
    $scope.names =[
        {name:'Danial Pervaiz' , city:'Denver'},
        {name:'David Johnson' , city:'Jamaica'},
        {name:'David Hopsin' , city:'Australia'}
    ];
   }
 </script>

1 个答案:

答案 0 :(得分:0)

您尚未在任何地方定义模块或提及的ng-app.Here is working Jsfiddle