I've been diving into the Angular Style Guide, but a question has come up: what is the most effective method for initializing a variable in a component?
For instance, should I declare a variable like so:
export class MyComponent implements OnInit {
myModel: MyModel= new MyModel();
//...
}
Or perhaps like this:
export class MyComponent implements OnInit {
myModel = new MyModel();
//...
}
Or maybe like this:
export class MyComponent implements OnInit {
myModel: MyModel;
constructor() {
this.myModel = new MyModel();
}
//...
}
Is there another optimal approach that I should be aware of? You can find the Style Guide that I've been referencing here.