Answer the question
In order to leave comments, you need to log in
Angular Adding records?
Hello, I have two questions:
1) How can I make it so that when adding a new record, the form for adding appears not at the end, but at the beginning of the table?
2) How to make a ban on adding a new record if the previous form for adding a record was not saved or canceled before?
Answer the question
In order to leave comments, you need to log in
1. To make the addition appear at the beginning of the table, insert the element at the beginning of the array:
2. Add a property that will store the state (boolean), whether the form is open or not, and in the template, disable the button by this property:
component:
private isOpenForm: boolean = false;
// Добавление записи
createPost() {
this.isOpenForm = true;
this.sprBitType = new SprBitType(0,"",false,0);
this.sprBitTypes.push(this.sprBitType);
this.isNewRecord = true;
}
saveSprBitType() {
this.isOpenForm = false;
........................
........................
}
cancelSprBitType() {
this.isOpenForm = false;
........................
........................
}
<button class="btn -primary" (click)="createPost()" [attr.disable]="isOpenForm">Добавить</button>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question