我想從一個JSON文件中提取一個值來設置一個模板URL。該值將成爲Angular獲取模板內容的URL。基本上,我想拿出某種形式的解決方案,使得所需的HTML模板可以由用戶在後臺設置,和我的角度服務發出請求到S3,這臺templateUrl.
Angular 2 - 從變量設置templateUrl?
import { Component, OnInit } from '@angular/core';
import { GlobalDirective } from '../../global.directive';
@Component({
selector: 'terms-form',
//need to be able to specify this templateUrl as a variable from the JSON sitting on S3.
templateUrl: URL value from JSON,
styleUrls: ['./terms.component.css']
})
export class TermsFormComponent implements OnInit {
constructor(public globalDirective: GlobalDirective) {}
ngOnInit() {
this.globalDirective.getData();
} }
我在這裏發現了一些類似的問題,但沒有爲我的問題工作。我正在使用@angular/cli: 1.0.1
請問此處的信息幫助 在我的情況IM:https://angular.io/docs/ TS /最新/菜譜/動態組件loader.html – DeborahK