Angular2のComponentに指定するテンプレートを動的に変更することは可能でしょうか?
同一のComponentで、条件に応じて異なるテンプレートを利用したいです。
海外のサイトなどでも調べてみたのですが、
同じことをやりたい人はいるけれども
http://stackoverflow.com/questions/31692416/dynamic-template-urls-in-angular-2
いまいちやりたいことを実現している回答がなかったので質問させていただきました。
以下のコードは動きませんが、やりたいイメージはこういう感じです。
typescript
1@Component({ 2 selector: 'my-component' 3}) 4@View({ 5 // 動かない 6 templateUrl: this.templateFile 7}) 8class MyComponent { 9 templateFile: string; 10 constructor() { } 11 12 button1_click(){ 13 this.templateFile = 'template1.html'; 14 } 15 16 button2_click(){ 17 this.templateFile = 'template2.html'; 18 }
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。