编译代码时出现此错误:找不到名称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);
};
}
答案 0 :(得分:17)
您忘记从SimpleChanges
导入@angular/core
界面。
import { SimpleChanges } from '@angular/core';