I want to change at my api, selected: true
when i click on current Inventory.
Can i do something like this ?
app.controller('InventoryDetailCtrl', function($scope, Inventory, Assigned, Tags, Restangular, currentInventory) {
$scope.inventories = new Inventory().query().$object;
$scope.selected = function(id) {
for(var i = 0; i < $scope.inventories.length; i++){
if($scope.inventories[i].id == id){
console.log(id);
var selectedInventory = Restangular.copy($scope.currentInventory);
selectedInventory.customPUT({selected: True });
}
}
};
});
Here i got my states, where i get my current Inventory
.state('inventory.detailview',{
url:'/detailview',
views: {
"main": {
controller: 'InventoryDetailCtrl',
templateUrl: 'inventory/detail.tpl.html'
}
},
resolve: {
currentInventory: function($stateParams, Inventory){
return new Inventory().get($stateParams.id).$object;
}
and in my template i do like this
<div ng-repeat="inventory in inventories">
<a href="" ng-click="selected(inventory.id)">{{inventory.name}}</a>
</div>