i have the code working onInit but not onChanges.
here is code from component
import { Component, Input, OnInit, OnChanges, SimpleChanges } from '@angular/core';
export class FetchDataComponent implements OnChanges {
site: string[] = [];
@Input() values: string = "https://angular.io";
onEnter(value: string) { this.values = value; } // this is to get value from input field
ngOnChanges(changes: SimpleChanges) {
var slog = this.values;
this._httpService.get('/api/websites/?angular='+slog).subscribe(values => {
this.site= values.json() as string[];
});
}
i tried to follow the guide https://www.concretepage.com/angular-2/angular-2-4-onchanges-simplechanges-example which is targeting angular 4.
the same code was working with onInit but i need it to monitor the changes made onChanges
ngOnChanges()is not firing? Did you try addingconsole.log()and checked? - Amit Chigadani