2014-03-07 29 views
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'); 

}

回答

0

如果您正在使用的用戶界面的路由器,你可以使用stateParams

app.controller('InventoryCtrl', function($scope,$stateParams,Inventory) { 
    $scope.id = $stateParams.id; 
} 
+0

當我添加這個,並將控制器狀態更改爲'InventoryCtrl'我得到了'inventory/description /:%7B%7D' stateParams.id將如何知道inventorys id? – user3305175

+0

%7B%7D是{},當你配置你的狀態時,你似乎有錯誤:'url:'/ inventory/description /:{{id}}'' - >'url:'/ inventory/description/{id }'' –

+0

不能正常工作.... – user3305175

相關問題