I have an Edit Form, where users can Update a single "auction". How can I use $state.go('auctions') correctly within the update function, so that the user gets directed to the auction-view after the update was successfull?
Or better: how can I pass parameters to this $state.go('auctions')
// Update auction
$scope.updateAuction = function(auction){
auctions.updateAuction(auction, {
product: $scope.product,
condition: $scope.condition
}).success(function() {
$state.go('auctions'); // I think I need to add auction parameters here
ToastService.show('Auction updated');
});
};
The auctions $state function looks like this:
// state for showing single Auction
.state('auctions', {
url: '/auctions/{product}/{id}',
templateUrl: 'auctions/auction-view.html',
controller: 'AuctionViewCtrl',
resolve: {
auction: ['$stateParams', 'auctions', function($stateParams, auctions) {
return auctions.get($stateParams.id);
}]
}
})
The Edit Form can only be accesed through the related Auction View, so maybe there is a better option to use $state.go without sending a new GET request, because the auction is already loaded?
$state.go("auctions", {"product": auction.product, "id": auction.id});
Here is also a link with documentation:
https://github.com/angular-ui/ui-router/wiki/Quick-Reference#stategoto--toparams--options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With