When the code is compiled i get this error: Cannot find name SimpleChanges. I am new to Angular 2, could you possibly help me find where the error is? Here's my home.ts:
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);
};
}
You forgot to import SimpleChanges
interface from @angular/core
.
import { SimpleChanges } from '@angular/core';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With