为什么我会收到此错误?我正在使用AngularJS 1.3.15
app.js文件:
(function () {
'use strict';
var app = angular.module('productManagement', ['common.services']);
}());
productListCtrl.js文件:
(function () {
'use strict';
angular
.module('productManagement')
.controller('productListCtrl', ['productResource', productListCtrl]);
function productListCtrl(productResource) {
var vm = this;
productResource.query(function (data) {
vm.prodcts = data;
console.log(vm.prodcts);
//alert(vm.prodcts);
});
}
}());
productListView.html文件
<div class="panel panel-primary" ng-controller="ProductListCtrl as vm">
<div class="panel-heading">Product List</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<td>Product</td>
<td>Code</td>
<td>Available</td>
<td>Price</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="product in vm.products">
<td>{{product.productId}}</td>
<td>{{product.productCode}}</td>
<td>{{product.releaseDate | date}}</td>
<td>{{product.price | currency}}</td>
</tr>
</tbody>
</table>
</div>
</div>
和我的index.html文件链接:
http://pastebin.com/vwaLPyUH
最佳答案
您已将控制器定义为productListCtrl
,但使用ProductListCtrl
,因此会出现错误。
采用
<div class="panel panel-primary" ng-controller="productListCtrl as vm">
代替
<div class="panel panel-primary" ng-controller="ProductListCtrl as vm">
关于javascript - 参数“ProductListCtrl”不是函数,未定义,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30545617/