Where should Angular's [FormControl].valueChanges.subscribe() be located, ngOnInit() or constructor()?

347 Views Asked by At

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) => {
            //
        });
    }
0

There are 0 best solutions below