[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2016-01-08 Thread Brian Troncone
Martin, Thanks for your reply. We did something similar by setting a static on the service to an instance of itself when constructed. As you said though, this sort of thing is hideous and breaks DI so I'm really hoping Sander can instruct us on a better solution, or one in the works. I

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2016-01-08 Thread Brian Troncone
Sander, One example use-case shows itself in a business application I am building, which requires role based authentication throughout the navigation structure. For example, each user is only allowed access to certain sections of the site after they authenticate. The active user's roles are

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-22 Thread Sander Elias
Hi Manfred, Martin. There is a good reason there is no support for this. It leads to tightly coupled code, and the code tends to land 'far' away from where it belongs. The easy solution is to create a service that checks the thing you need, and then just assign that to the canActivate lifetime

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-22 Thread Martin Kuhn
Sorry I strongly disagree. I do the route config already on the "app" component. I don't see "coupling" -> I see this as cross cutting concern. So I have to inject the "router logic" service into every Component and have to ask the service. The decision should really be made by the developer.

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-22 Thread Manfred Steyer
Hi Sander, I think it depends on the use case and I also think the framework should give us the possibility so that we can decide. But I'm curious: Do you know for sure, that this is not supported? Wishes, Manfred Am Dienstag, 22. Dezember 2015 11:21:40 UTC+1 schrieb Sander Elias: > > Hi

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-22 Thread Martin Kuhn
I don't see the big win for maintainability. The logic for the decision is probably in a service. So you have to inject this service into every component and implement "canActivate" . Only for calling the service which makes the decision Regards Am Dienstag, 22. Dezember 2015 14:41:46 UTC+1

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-22 Thread Sander Elias
Hi Manfred, So, I did a quick check, and didn't find anything that convinces me it has changed. I think your use case can be quickly resolved by using the routerCanDeactivate lifecycle method, of the component that

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-22 Thread Sander Elias
Hi Martin, No, you shouldn't need to inject it everywhere. Usually there is no need for that. If you make sure that at a higher-level component the check is done. See, for the router your app has a tree-like structure. You can put an can(de)activate on every branch, and/or even at the base.

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-22 Thread Sander Elias
Hi Manfred, - Providing metadata for components to state that they can be accessed by > unauthenticated users, something like @Auth({anonymous:true}) > - Using event to prevent unauthenticated users to access components > without this directive or with @Auth({anonymous:false}) > Well, the

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-22 Thread Manfred Steyer
Hi Sander, thanks for checking this and for your answers. I think a good use case would look like this: - Providing metadata for components to state that they can be accessed by unauthenticated users, something like @Auth({anonymous:true}) - Using event to prevent unauthenticated users to

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-21 Thread Manfred Steyer
Hi Eric, thanks, but this isn't excactly what I'm looking for. I'm really seeking a global event that isn't associated with a specific component. Something like a generic CanActivate that kicks in for every component or something like $stateChangeStart in UI Router. Is there something like

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-21 Thread Martin Kuhn
I can not believe that this common use case is not handled by the new router (I hope I am not wrong). Especially when you consider how long the router is in the works already... -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from

[AngularJS] Re: Angular 2: Global Hooks/ Events for Component Router

2015-12-21 Thread Eric Martinez
I think you're looking for CanActivate -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to