Reputation: 1618
I am working on a Single Page Application. Page A , Page B are partials. We have a button "btnA" on "Page A" rendered using "controllerA". At click of "btnA" we need to perform "serviceA.somework()" and at successful completion, load "Page B" using "controllerB" with some params.
Is following the best way to achieve this?
within controllerA.onClickBtnA() { $location.path(PageB).search({param:'value'})}
Upvotes: 1
Views: 46
Reputation: 9560
$routeProvider
is the best choice for your scenario. You should not load the controller manually in any way. The Angular router
does the job for you.
A simple example from the angular official API page: http://plnkr.co/edit/foLnNL7koXzUYavnYFFw?p=preview.
Your proposal is basically doing what $routeProvider
does. $routeProvider
provides:
resolve
function to control access to current pathAnd it is well tested and supported. You'd better have a try.
Upvotes: 1