我想用「controller as」與ng-repeat
但我無法訪問html中的數據。下面是代碼片段:「Controller as」語法不能與ng-repeat配合使用
控制器JS:
angular.module('myApp')
.controller('reportController', function (reportCandidate) {
reportCandidate.query(function(response){
//$scope.candidateInfo = response;
this.candidateInfo=response;
})
})
.factory('reportCandidate', ['$resource', function ($resource) {
return $resource('http://localhost:3000/records', {});;
}]);
app.js:
'use strict';
angular.module('myApp', [
'ui.router',
'ngResource',
'myApp.version'
])
.config(['$urlRouterProvider','$stateProvider', function($urlRouterProvider, $stateProvider) {
$urlRouterProvider.otherwise('/viewDashboard');
$stateProvider.state('viewReport', {
url: '/viewReport',
templateUrl: '../viewReport/viewReport.html',
controllerAs: 'report',
controller: 'reportController'
});
}]);
HTML:
<tr ng-repeat="data in candidateInfo">
<td>{{data.name}}</td>
<td>{{data.profession}}</td>
<td>{{data.skill}}</td>
<td>{{data.exp}}</td>
<td>{{data.gender}}</td>
</tr>
我應該我在HTML改變得到的數據顯示?
使用'report.candidateInfo' –