2013-11-21 120 views
0

我試圖顯示使用角度加載通過需求的項目列表。如何使用角度與要求

我有兩個文件

的index.html

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title>Test App</title> 
    <script data-main="/Scripts/app/main" src="../Scripts/lib/require.js"></script> 
</head> 
<body ng-controller="AppCntrl"> 
    <ul> 
     <li ng-repeat="phone in appCntrl.phones"> 
      {{phone.name}} 
      <p>{{phone.snippet}}</p> 
     </li> 
    </ul> 
</body> 
</html> 

和main.js

require.config({ 
    baseUrl: '/Scripts/', 
    urlArgs: "bust=" + (new Date()).getTime(), 
    paths: { 
       'angular': 'lib/angular/angular.min', 
       'angular-resource': 'lib/angular/angular-resource.min' 
    }, 
    shim: { 
       'angular': { 'exports': 'angular' }, 
       'angular-resource': { deps: ['angular'] } 
    } 
}); 

require(['angular', 'angular-resource'], function (angular) { 
    var mainMod = angular.module('mainMod', ['ngResource']); 
    mainMod.controller('AppCntrl'['$scope', function ($scope) { 
     $scope.phones = [ 
      { 
      'name': 'Nexus S', 
      'snippet': 'Fast just got faster with Nexus S.' 
      }, 
      { 
      'name': 'Motorola XOOM™ with Wi-Fi', 
      'snippet': 'The Next, Next Generation tablet.' 
      }, 
      { 
      'name': 'MOTOROLA XOOM™', 
      'snippet': 'The Next, Next Generation tablet.' 
      } 
     ]; 
    }]); 
    angular.bootstrap(document, ['mainMod']); 
}); 

我沒有得到任何控制檯錯誤。只是一個空白頁面

UPDATE

我做了更新,現在越來越錯誤[NG:AREQ]我認爲這是一種進步

UPDATE2

我沒有得到錯誤

Cannot call method '$$minErr' of undefined 

UPDATE 3

Error: [ng:areq] 
+1

'AppCntrl'後缺少逗號。 – Stewie

回答

1

我不知道你爲什麼要求角度資源,它似乎是不需要的。如果您使用1.2.0,則需要角路由。而「appCntrl.phones」應該只是「手機」。

Plunker