I am using Yeoman's angular-fullstack and am stuck on making multiple views based on Mongo's auto generated _id. The StoreCtlr, which populates all data to the pag,e works well, I am just having trouble passing in the parameter into the StoreShowCtrl
My controller is below:
storeControllers.controller('StoreShowCtrl', ['$scope', '$routeParams','$http',
function($scope, $routeParams, $http) {
$http.get('api/items'+$routeParams.items._id).success(function(detail) {
$scope.data = detail;
});
}
]);
I am routing with
.when('/product/:id', {
templateUrl: 'app/product/product.html',
controller: 'StoreShowCtrl'
});
Thank you for your help!
答案 0 :(得分:0)
在控制器中使用 $ routeParams.id 而不是 $ routeParams.items._id ,因为您在定义状态时提到了 id 作为参数。 这将有效。