这是我想要执行,并在app.component.ts我需要执行一个功能每x秒角2和打字稿
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'中? – jonrsharpe
您应该使用(加载)='...'作为角度上下文。 – rjustin
如果我已经可以使用OnInit接口找到解决方案并在函数ngOnInit(){} –