0

我是 Angular 的新手,当我使用 ng-repeat 时,它不起作用。

<script type="text/javascript">
  var another_app = angular.module('list_app',[]);
  another_app.controller('list_ctrl',function($scope){
    $scope.values=[1,2,3,4];
  });
</script>

<p ng-app='list_app' ng-controller='list_ctrl' ng-repeat="x in values">{{x}}</p>
4

1 回答 1

0

ng-app&分配ng-controller给不同的 dom 元素

var another_app = angular.module('list_app', []);
another_app.controller('list_ctrl', function($scope) {
  $scope.values = [1, 2, 3, 4];
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>

<div ng-app='list_app' ng-controller='list_ctrl'>
  <p ng-repeat="x in values">{{x}}</p>
</div>

于 2019-08-04T09:12:24.510 回答