Angular 2检查模板URL是否存在?

时间:2017-11-07 08:35:12

标签: angular

@Component({
 selector: 'app-selectb',
 template: `<div  [innerHTML]="sanitizer.bypassSecurityTrustHtml(this.url)">
 </div>`
})

export class SelectComponent implements OnInit {
@Input() abi:string;
url: string;


constructor(public sanitizer:DomSanitizer) {
}

ngOnInit() {
var myId;
var myLanguage;
myId = $("div[name=check]").attr('data-abi');
myLanguage = $("div[name=check]").attr('data-lang');

if(myId==undefined || myId=="" || !(require('./banche/'+myId+'/it/file.html'))){
  myId='default';
}

this.url = require('./banche/'+myId+'/'+myLanguage+'/file.html');
require('style-loader!./banche/'+myId+'/style.css');
}

}

我想知道html文件是否存在于路径中,变量myId必须变为&#34;默认&#34; (有一个默认路径,默认名称)。谢谢:))

0 个答案:

没有答案