Florovit
Florovit

Reputation: 27

Switch to another angular view in controller

Is possible to switch to another angular view in controller? I meant something like this:

function ItemController($http, $routeParams) {
   $http.get('/api/item/' + $routeParams.ItemId).then(function(response) {
       self.related_item = response.data['related_item_id'];
       if (self.related_item != 10) {
           switch_to_another_view('#!/items/' + self.related_item);
       }
   });
}

Upvotes: 0

Views: 49

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222522

If you are using angular-router or $routeProvider, do it as:

$location.path('items')

Upvotes: 1

Related Questions