【发布时间】:2017-09-25 21:26:26
【问题描述】:
这是我要执行的功能,在 app.component.ts 中
public goLocalization() :void {
this.localizationService.getLocalizationHttp().then(response => {
localStorage.setItem("locatios", JSON.stringify(response));
});
console.log('goLocalization');
}
从这里我正在拨打电话,但它没有执行并且出错
<body onLoad="setInterval('goLocalization()',1000);"></body>
这是错误
Uncaught ReferenceError: goLocalization is not defined
at <anonymous>:1:1
【问题讨论】:
-
为什么不在应用组件类的
ngOnInit中这样做? -
您应该使用 (load)='...' 作为角度上下文。
-
如果我已经找到了使用 OnInit 接口并在函数 ngOnInit () {} 中使用的解决方案
标签: html angular typescript html5-video