2014-03-30 96 views
0

這是一個簡單的角度控制器,但不起作用。我無法找到任何代碼問題。你可以嗎 ?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

添加ng-app。 Angular需要它爲角度指定文檔的根。

<html ng-app> 
+0

Ops.Thanks #Shamed – user3418042