Do I use routes or a directive?

24 views
Skip to first unread message

Reza Razavipour

unread,
May 9, 2018, 4:49:16 PM5/9/18
to Angular and AngularJS discussion
I have an angular 4 app, almost identical to gmail. 
A column of buttons each with a corresponding "component" to get displayed on the right of the buttons.

I used ngSwitch to do this but the component would get recreated from scratch since it was not in the DOM anymore.
That seems inefficient, is there another directive that I can use to just simply effectively change the z-order of the custom components, put the correct one on the top...

Or is it a natural fit for routing? A route for each custom component that shows up on the right side?

Thoughts or guidance? 

Sander Elias

unread,
May 10, 2018, 2:15:41 AM5/10/18
to Angular and AngularJS discussion
Hi Reza,

I would say router. 
Also, you don't want your components destroyed? (router will do that too!). Why not?

Regards
Sander

Reza Razavipour

unread,
May 10, 2018, 11:27:45 AM5/10/18
to ang...@googlegroups.com
destroyed would mean, recreated, data re-gotten and re-renderered, etc...

No way to avoid the the destruction and redoing the work that was done before?

Regards,
Reza

--
You received this message because you are subscribed to a topic in the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/Cf6z3uZd8X8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+unsubscribe@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Zlatko Đurić

unread,
May 11, 2018, 1:41:25 AM5/11/18
to Angular and AngularJS discussion
Sure there's a way. But the question is, why do you fetch the data from the _component_ each time, perhaps you can keep the data on a service and then define your triggers for refreshing the data.


On Thursday, May 10, 2018 at 5:27:45 PM UTC+2, Reza Razavipour wrote:
destroyed would mean, recreated, data re-gotten and re-renderered, etc...

No way to avoid the the destruction and redoing the work that was done before?

Regards,
Reza

On Wed, May 9, 2018 at 11:15 PM, Sander Elias <sande...@gmail.com> wrote:
Hi Reza,

I would say router. 
Also, you don't want your components destroyed? (router will do that too!). Why not?

Regards
Sander

--
You received this message because you are subscribed to a topic in the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/Cf6z3uZd8X8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages