sonicoder86 / angular2-babel-esnext-starter

Angular development and testing examples with Babel in Javascript (ES6/ES7).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace router outlet override with @CanActivate check

mdhanda opened this issue · comments

First of all, I loved the way you put this Esnext app to give a quick start. It worked straight in. Although, while I was putting a few goodies from AngularClass starter, I faced this "Primary outlet is already registered." issue. And then, I came across this link to completely different approach. Can you put your suggestions/reasons like which approach is good and why one should be preferred?

Here is the link:
timdp/angular2-sub-bay@849dec8#diff-6496a4309e4f6d55070a07d30e0eaf87

With this code snippet you are actually monkey patching the lack of DI in @CanActivate.

.then((app: any) => { Context.injector = app.injector; })
 +  .catch((err: any) => console.log(err));

Well, yes.. kind-of monkey patching, but gives a nice way of DI.
Apart from that, When I put this all in app, I am continuously getting below error:

Uncaught Error: Cannot find module "../../context"

(Note: there is no import path issue, I can confirm)
Does it have anything to do with statics used in context.js???
Any pointer would be great. Thanks.

UPDATE:
Nevermind, I did it the way suggested in [router] CanActivate and DI #4112
Thanks.

With the new router it will move to a canActivate guard object anyway