I have a form where inputs are bound to object one-way.
<input type="text" name="lastName" #lastName="ngModel" [ngModel]="selectedPers.lastName" required minlength="2">
When saving form I read form data and send it to server, then update my model with dummy/empty data to clear it out.
this.peopleListObservable.push(newPersonFormData).then(a => {
this.clearPers();
})
clearPers() {
this.selectedPers = this.dummyPers;
this.isPersAdd = true;
}
This clear-out method is separate and works when I call it from a button click, but it doesn't work/clear form if I call it after sending my data to server in my save promise then
method.
Any ideas why I experience such behavior and what shall I do to clear out my form?
EDIT: I've changed clearPers function like so with hope to reload the page:
clearPers() {
console.log('Inside clearPers function');
this.router.navigate(['/person/' + this.key]);
}
guess what, console log is printed but router navigation didn't happen.
What am I missing?
EDIT 2: Thanks @FabioAntunes for reminding me that router idea wouldn't work anyways.
EDIT 3: Question is asked for a project with Angular 2 RC4 release. Read below my answer for what happened later and is supposed to happen in final release of Angular2.