2015-01-05 60 views
0

我有以下代碼:顯示一個列表角

<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頁面上是{{結果}}和{{image.votes}}像角不工作.. 。我也檢查了API,它不叫...

我錯過了什麼?

+1

檢查控制檯,我懷疑你的模塊定義是無效的,你錯過的依賴陣列爲一體,VAR應用= angular.module(拼寫錯誤'應用',[]); –

+0

我補充說,{{image.votes}}部分不會消失,API不會被調用,而{{result}}會出現,而不是其字符串。任何想法? –

+0

檢查數據對象中是否有任何數據 – joey

回答

5

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

控制器,帶2 L的