What is the difference, if any, between:
@Output() exampleChange: EventEmitter<Example> = new EventEmitter();
and
@Output() exampleChange = new EventEmitter<Example>();
What is the difference, if any, between:
@Output() exampleChange: EventEmitter<Example> = new EventEmitter();
and
@Output() exampleChange = new EventEmitter<Example>();
No difference, is practically the same.
This defines the type and then initializes it:
@Output() exampleChange: EventEmitter<Example> = new EventEmitter();
This is initialized directly:
@Output() exampleChange = new EventEmitter<Example>();
I recommend using the second way
think about it when you set a variable in a component
export class MyTestComponent {
myNumber:number = 10;
}
-------------------------------------
export class MyTestComponent {
myNumber = 10;
}
In both examples, I created a variable that calls myNumber and set his value to 10, but in the second one, I gave it a type. in JS there is no difference between the code except the good order of the script