angular 动态分配模板
angular dynamically assign template
我需要使用来自@angular/youtube-player 的 youtube 播放器,但我需要 videoId 是动态的。是否可以为组件装饰器分配变量?
我试过了,但出现错误:
const videoId = localStorage.setItem('videoId}', welcomeInfo.imageVideoUrl);
@Component({
template: `<youtube-player
videoId=${videoId}
suggestedQuality="highres"
[height]="600"
[width]="1080"
[startSeconds]="43"
[endSeconds]="60">
</youtube-player>`,
selector: 'app-video'
})
要为 youtube-player
动态分配 videoId,您可以执行以下操作:
@Component({
template: `<youtube-player
[videoId]="videoId"
suggestedQuality="highres"
[height]="600"
[width]="1080"
[startSeconds]="43"
[endSeconds]="60">
</youtube-player>`,
selector: 'app-video'
})
我需要使用来自@angular/youtube-player 的 youtube 播放器,但我需要 videoId 是动态的。是否可以为组件装饰器分配变量?
我试过了,但出现错误:
const videoId = localStorage.setItem('videoId}', welcomeInfo.imageVideoUrl);
@Component({
template: `<youtube-player
videoId=${videoId}
suggestedQuality="highres"
[height]="600"
[width]="1080"
[startSeconds]="43"
[endSeconds]="60">
</youtube-player>`,
selector: 'app-video'
})
要为 youtube-player
动态分配 videoId,您可以执行以下操作:
@Component({
template: `<youtube-player
[videoId]="videoId"
suggestedQuality="highres"
[height]="600"
[width]="1080"
[startSeconds]="43"
[endSeconds]="60">
</youtube-player>`,
selector: 'app-video'
})