M.T*_*M.T 2 timer typescript angular
编译代码时,我收到此错误:找不到名称SimpleChanges.我是Angular 2的新手,你能帮我找到错误的位置吗?这是我的家.
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {Observable} from 'rxjs/Rx';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
date: Date;
constructor(public navCtrl: NavController) {
this.date = new Date();
}
ticks = 0;
ngOnChanges(changes: {[propertyName: string]: SimpleChanges}){
if(changes['ticks']){
if(this.ticks == 20)
this.ticks = 0;
}
}
ngOnInit(){
let timer = Observable.timer(0,1000);
timer.subscribe(t=>this.ticks = t);
};
}
Run Code Online (Sandbox Code Playgroud)
ran*_*al9 19
你忘了从中导入SimpleChanges界面@angular/core.
import { SimpleChanges } from '@angular/core';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5957 次 |
| 最近记录: |