0
我想通過身份證訪問庫存,使用鏈接/inventory/description/:{{id}}
但它沒有工作,什麼都沒有顯示出來。我如何通過ID訪問它?我如何通過身份證到我的用戶界面
app.config(function config($stateProvider, $urlRouterProvider) {
$stateProvider.state('inventory',{
url:'/inventory',
views: {
"main": {
controller: 'InventoryCtrl',
templateUrl: 'inventory/main.tpl.html'
}
},
data:{ pageTitle: 'Inventory' }
}
).state('inventory.detailview',{
url:'/inventory/detailview',
views: {
"detailview": {
controller: 'InventoryCtrl',
templateUrl: 'inventory/detail.tpl.html'
}
},
data:{ pageTitle: 'DetailView' }
}
).state('inventory.description',{
url:'/inventory/description/:{{id}}',
views: {
"descriptionview": {
templateUrl: 'inventory/description.tpl.html',
controller: function($scope, Inventory){
$scope.id = Inventory.query('id');
}}
},
data:{ pageTitle: 'DescriptionView'}
});
});
我廠
app.factory('Inventory', function($resource, $http) {
return $resource('http://web.lv/api/v1/inventory/:id', {id: "@id"},
{
update: {
method: 'POST',
params: {id: '@id'},
isArray: false
},
save: {
method: 'PUT'
},
query: {
method: 'GET',
params: {id: '@id'},
isArray: false
},
create: {
method: 'POST'
},
drop: {
method: 'DELETE',
params: {id: "@id"}
}
}
);
});
我控制器
app.controller('InventoryCtrl', function($scope, $http, Inventory, $location) {
//getting the objects from Inventory
$scope.info = Inventory.query();
//
$scope.id = Inventory.query('id');
}
當我添加這個,並將控制器狀態更改爲'InventoryCtrl'我得到了'inventory/description /:%7B%7D' stateParams.id將如何知道inventorys id? – user3305175
%7B%7D是{},當你配置你的狀態時,你似乎有錯誤:'url:'/ inventory/description /:{{id}}'' - >'url:'/ inventory/description/{id }'' –
不能正常工作.... – user3305175