Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 Cannot find name SimpleChanges

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);
  };



}
like image 897
M.T Avatar asked Nov 29 '22 13:11

M.T


1 Answers

You forgot to import SimpleChanges interface from @angular/core.

import { SimpleChanges } from '@angular/core';
like image 125
ranakrunal9 Avatar answered Dec 05 '22 08:12

ranakrunal9