I am studing Angular Style Guide, but I have a doubt, what's the best way to initialize a variable in component?
For example, I declare a variable like this:
export class MyComponent implements OnInit {
myModel: MyModel= new MyModel();
//...
}
Or like this:
export class MyComponent implements OnInit {
myModel = new MyModel();
//...
}
Or this:
export class MyComponent implements OnInit {
myModel: MyModel;
constructor() {
this.myModel = new MyModel();
}
//...
}
Or another best way? Here's the Style Guide I was reading.
Aucun commentaire:
Enregistrer un commentaire