Can I change the dynamic change of the Url template in angular 2?

I want to dynamically change my urll pattern, I read Dynamic Pattern URLs in Angular 2 . Yes, I can change my template before initializing the component. But what I want is when I click the button and change the URL, then my html is updated as a two way data binding.

I am trying to make my component as follows:

templateUrl: (function() { return dynamicURl; }()) 

But when changing "dynamicUrl" nothing happened. I also use dynamicComponentLoader to load my component again, and the component does not change.

+5
source share
1 answer

You cannot currently do this in angular 2 (alpha 48 version). You can link to: https://groups.google.com/forum/#!topic/angular/ROkKDHboWoA ,

https://github.com/angular/angular/issues/2753

There is a similar question: Dynamic template in templatURL in angular2

It seems like they are not planning on including this, you would like to write your own function to fill the div with dynamic content. Or a similar attribute directive.

+7
source

Source: https://habr.com/ru/post/1236408/


All Articles