javascript - AngularJS 2 Alternate StyleUrsl/TemplateUrl -


i have component i'm trying inject different styleurl or templateurl based on object initialized when component loads.

@component({   moduleid: module.id,   selector: 'my-sample',   templateurl: './sample.html',   styleurls: ['./sample.css'],   providers: [userservice] })  export class samplecomponent implements oninit {   sampleentity: sampleentity[];    constructor(private userservice: userservice){}    getuserentity():void {     this.sampleentity = this.userservice.getuserobject();   }    ngoninit():void {     this.getuserentity();   } } 

my object initialized (sampleentity) looks this:

  { id: 1,  usertype: 'creative' },   { id: 2, usertype:'boring'} 

is there way can used angular expressions load specific templateurl or styleurl based on object assigned?

for example:

 @component({   moduleid: module.id,   selector: 'my-sample',   templateurl: './{{sampleentity[0].usertype}}.html',   styleurls: ['./{{sampleentity[1].usertype}}.css'],   providers: [userservice] }) 


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -