使用Angular显示列表

时间:2015-01-05 16:05:25

标签: angularjs

我有以下代码:

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

<script type="text/javascript">
  var application = angular.module('Application');

  application.controller('ImageController', function ImageController($scope, $http) {

    $scope.result = "Start here ...";

    $http.get('api/images').
      success(function (data, status, headers, config) {
        $scope.images = data;
        $scope.result = "Everything is ok";
      }).
      error(function (data, status, headers, config) {
        $scope.result = "Something went wrong";
      });

  });
</script>

<div ng-app="Application" ng-controller="ImageControler">

  <p>{{result}}</p>
  <div ng-repeat='image in images'>
    <span>{{image.votes}}</span>
  </div>

</div>

我在呈现的HTML网页上获得的是{{result}}和{{image.votes}},例如Angular无效...我还检查了API并且没有调用它...

我错过了什么?

1 个答案:

答案 0 :(得分:5)

<div ng-app="Application" ng-controller="ImageControler">

中有拼写错误

2 L&#39的控制器