我是一个完整的新手,请帮忙! :)
我正在尝试访问/产品页面,并且由于此错误而未返回任何数据:错误:[ng:areq]参数' ProductsController'不是一个功能,未定义。我正在使用https://github.com/jpotts18/mean-stack-relational
公共/ JS / app.js
angular.module('mean', ['ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mean.system', 'mean.articles', 'mean.products']);
angular.module('mean.system', []);
angular.module('mean.articles', []);
angular.module('mean.products', []);
公共/ JS / config.js
'use strict';
//Setting up route
angular.module('mean').config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/articles', {
templateUrl: 'views/articles/list.html'
}).
when('/articles/create', {
templateUrl: 'views/articles/create.html'
}).
when('/articles/:articleId/edit', {
templateUrl: 'views/articles/edit.html'
}).
when('/articles/:articleId', {
templateUrl: 'views/articles/view.html'
}).
when('/products', {
templateUrl: 'views/products/list.html',
controller: 'ProductsController'
}).
when('/products/create', {
templateUrl: 'views/products/create.html'
}).
when('/products/:productId/edit', {
templateUrl: 'views/products/edit.html'
}).
when('/products/:productId', {
templateUrl: 'views/products/view.html'
}).
when('/', {
templateUrl: 'views/index.html'
}).
otherwise({
redirectTo: '/'
});
}
]);
//Setting HTML5 Location Mode
angular.module('mean').config(['$locationProvider',
function($locationProvider) {
$locationProvider.hashPrefix("!");
}
]);
公共/控制器/ product.js
'use strict';
angular.module('mean.products').controller('ProductsController', ['$scope', '$routeParams', '$location', 'Global', 'Products', function ($scope, $routeParams, $location, Global, Products) {
$scope.global = Global;
$scope.create = function() {
var product = new Products({
title: this.title,
content: this.content
});
product.$save(function(response) {
console.log(response);
$location.path("products/" + response.id);
});
this.title = "";
this.content = "";
};
$scope.remove = function(product) {
if (product) {
product.$remove();
for (var i in $scope.products) {
if ($scope.products[i] === product) {
$scope.products.splice(i, 1);
}
}
}
else {
$scope.product.$remove();
$location.path('products');
}
};
$scope.update = function() {
var product = $scope.product;
if (!product.updated) {
product.updated = [];
}
product.updated.push(new Date().getTime());
product.$update(function() {
$location.path('products/' + product.id);
});
};
$scope.find = function() {
Products.query(function(products) {
$scope.products = products;
});
};
$scope.findOne = function() {
Products.get({
productId: $routeParams.productId
}, function(product) {
$scope.product = product;
});
};
}]);
公共/视图/产品/ list.html
<section data-ng-controller="ProductsController" data-ng-init="find()">
<ul class="products unstyled">
<li data-ng-repeat="product in products">
<span>{{product.updatedAt | date:'medium'}}</span> /
<span>{{product.user.name}}</span>
<h2><a data-ng-href="#!/products/{{product.id}}">{{product.stockCode}}</a></h2>
<div>{{product.price}}</div>
</li>
</ul>
<h1 data-ng-hide="!products || products.length">No products yet. <br> Why don't you <a href="/#!/products/create">Create One</a>?</h1>
</section>