admin管理员组文章数量:1353289
I want to change my templateUrl dynamically, I've read Dynamic template URLs in Angular 2. Yes, I can change my template before the ponent initialize. But what I want is when I hit a button and the url change, then my html is update, like two way data binding.
I try make to my ponent like this:
templateUrl: (function() {
return dynamicURl;
}())
But when change the "dynamicUrl", not thing happened. I also use dynamicComponentLoader load my ponent again and ponent is not changed.
I want to change my templateUrl dynamically, I've read Dynamic template URLs in Angular 2. Yes, I can change my template before the ponent initialize. But what I want is when I hit a button and the url change, then my html is update, like two way data binding.
I try make to my ponent like this:
templateUrl: (function() {
return dynamicURl;
}())
But when change the "dynamicUrl", not thing happened. I also use dynamicComponentLoader load my ponent again and ponent is not changed.
Share Improve this question edited Dec 30, 2019 at 1:19 Louis L asked Nov 20, 2015 at 9:12 Louis LLouis L 4332 gold badges6 silver badges19 bronze badges 1- This is a out of date question. Angular only have rc version when I asked this question. Now, you have other ways to update the ponent template. – Louis L Commented Feb 7, 2021 at 3:35
1 Answer
Reset to default 7There is no way you can do it in angular 2 (alpha 48 version) as of now. You can refer to : https://groups.google./forum/#!topic/angular/ROkKDHboWoA ,
https://github./angular/angular/issues/2753
There is a similar question : Dynamic template in templatURL in angular2
As it seems that they are not planning to include this, you would like to write your own function to populate the div with dynamic content. Or a similar attribute directive.
本文标签: javascriptAm I able to change templateUrl in angular 2 dynamicallyStack Overflow
版权声明:本文标题:javascript - Am I able to change templateUrl in angular 2 dynamically? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743856741a2550992.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论