2014-10-29 40 views
0

工作下面的代碼在角1.2工作正常的,但它不上工作1.3全球控制器不是AngularJS 1.3

我應該改變,使其在1.3怎麼辦?

<!DOCTYPE html> 
<html data-ng-app=""> 

<head> 
<title>MyApp</title> 
</head> 

<body> 

<div class="wrapper" ng-controller="SimpleController"> 

    <div>Name:</div> 
    <div> 
     <input type="text" ng-model="filterword"> 
    </div> 

    <ul> 
     <li ng-repeat="person in contacts | filter: filterword | orderBy: 'name'" >{{ person.name }} lives in {{ person.city }}</li> 
    </ul> 

</div> 

<script> 
    var SimpleController = function($scope){ 
     $scope.contacts = [ 

      {name: 'Dave', 
      city: 'Dresden'}, 

      {name:'John', 
      city: 'Madrid'}, 

      {name:'Jane', 
      city: 'Berlin'} 
     ]; 
    } 
</script> 

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script> 

</body> 
</html> 
+1

[在簡單AngularJS示例控制器沒有定義錯誤]的可能重複(http://stackoverflow.com/questions/26517501/controller-not-defined-error-in-simple-angularjs-example) – 2014-10-29 21:06:12

+0

你說得對。我會重新構思這個問題,並自己回答 – 2014-10-29 21:10:45

回答

0

我發現,作爲this other thread解釋說,1.3版,全球控制器是不允許的,因爲它們產生相當混亂的代碼。

More info