Closed ArniDzhan closed 8 years ago
@petebacondarwin any advice on how to solve that?
Let me look into that!
The difficulty is that using templateUrl
causes the instantiation of the controller that contains the $routerOnActivate
is asynchronous... We can't even just use a $timeout
since we don't know how long it might take to receive the template request.
thanks, looks like there is a hack solution that should work since I am using template cache https://github.com/angular/angular/issues/4633
I am not sure why but using timeout like in this example doesn't seem to do it for me http://plnkr.co/edit/UzaDGOyeh6Qt7a0Wb22j?p=preview
Probably because the timeout is not long enough for the template to be retrieved?
Probably because the timeout is not long enough for the template to be retrieved?
tried setting more time but still nothing. Maybe coz angular_1_router.js changed and plnkr has an old version.
I think I have a final solution. Check out https://github.com/petebacondarwin/ng1-component-router-demo/commit/491061a802c4c2186d01b1a13b861a7cdaf61f41#diff-e0f5efa92aaa6eef271a9196ec90abc1R240
I think I have a final solution. Check out 491061a#diff-e0f5efa92aaa6eef271a9196ec90abc1R240
great, thanks for that. I can confirm that $routerOnActivate and $routerCanReuse work now.
one thing that would be nice to do is change require to routerRequire so that it works with browserify, otherwise require is trying to get the file. I can create PR with a fix
Thanks for putting this demo out, helped solve many issues. But there is something I've stumbled upon and though maybe you can help resolve.
if you change template to templateUrl in a code below then controller events like $routerOnActivate() stop triggering. https://github.com/petebacondarwin/ng1-component-router-demo/blob/master/app/crisis-center.js