无法使用ng-repeat在控制器中使用数组的angularjs中工作

时间:2017-06-05 14:26:22

标签: angularjs angularjs-ng-repeat

以下是我的代码。不确定为什么ng-repeat显示完全空白。

非常感谢任何帮助。

拉​​里

    <!DOCTYPE html>
    <html>
     <script 
  src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
     </script>
     <body>

         <div ng-app="myApp" ng-controller="myCtrl">
        <ul><li ngrepeat="x in names">{{x}}</li></ul> </div>

<script>
 var app = angular.module('myApp', []);
 app.controller('myCtrl', function($scope) {
 $scope.names = ["Emil","Tobias","Linus"];
});
</script>


</body>
</html>

1 个答案:

答案 0 :(得分:0)

修正拼写错误

  <!DOCTYPE html>
  <html>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"> </script>
  <body>
  <div ng-app="myApp" ng-controller="myCtrl">
      <ul><li ng-repeat="x in names">{{x}}</li></ul> </div>
<script>
   var app = angular.module('myApp', []);
   app.controller('myCtrl', function($scope) {
   $scope.names = ["Emil","Tobias","Linus"];
    });
</script>

</body>
</html>