Yes. Moreover, just do it if you want changes
<div *ngIf="transaction">Some edit stuff</div>
<div *ngIf="!transaction">Create stuff</div>
If you need specific material
ngOnInit() {
if(!this.transaction) {
} else {
}
}
EDIT : how would I do it (in your case)
This may not be the best solution, but should work (if I didn't get the syntax wrong)
ngOnInit() {
if(!this.transaction) {
this.transaction = new Transaction();
}
}
this way all class properties will be available, only empty. If you do not want them to be predefined, you can set them in the constructor or in ngOnInit.
source
share