0

I couldn't find a page in the Angular official documentation that explains where the best place for [FormControl].valueChanges.subscribe() is in ngOnInit() or constructor() . If you know the difference, please reply.

    readonly country = new FormControl<string>('', {nonNullable: true});

    constructor(
    ) { 
        this.country.valueChanges.subscribe((value) => {
            //
        });
    }

or

    readonly country = new FormControl<string>('', {nonNullable: true});

    ngOnInit(): void {
        this.country.valueChanges.subscribe((value) => {
            //
        });
    }
  • Does this answer your question? [Where to subscribe to an observable, constructor or ngoninit in Angular](https://stackoverflow.com/questions/64297512/where-to-subscribe-to-an-observable-constructor-or-ngoninit-in-angular) – CodeWarrior Mar 15 '23 at 04:08

0 Answers0