0

How to use any type of property in a component on ngOnchanges without @input property. I can not use Rxjs for this situation. It is not a child component so i have no @input property.
Please see the following example.

import { Component, OnInit, OnChanges, Input, TemplateRef, SimpleChanges } from '@angular/core';
@Component({
  selector: 'app-products',
  templateUrl: './products.component.html',
  styleUrls: ['./products.component.css']
})
export class ProductsComponent implements OnInit, OnChanges{  
    propertyName = "Default Text";
    constructor() { }
    
    // this.propertyName This property of value will be change any of 
    // this component 
    ngOnChanges(change:SimpleChanges){   
        console.log('ng on changes ...', change);
        // i want to fire here another Method up to change this property propertyName 
    }
  
    ngOnInit(): void {
        console.log('ng on Init ...');        
    }
}
Habib01
  • 63
  • 6
  • so you already know that clickhere function changes the property name , if you want the same input change effect just go for a settimeout function and set property name inside that function? – tknkrtl Jan 05 '22 at 08:13
  • this.propertyName Property of value can be changed anywhere in this componet – Habib01 Jan 05 '22 at 08:44
  • use getter and setter then, and write your function inside setter? https://stackoverflow.com/questions/12827266/get-and-set-in-typescript – tknkrtl Jan 05 '22 at 08:47

0 Answers0