Change field parent bind.
This commit is contained in:
parent
4064848242
commit
b95f36f09c
@ -14,11 +14,11 @@ import { Account } from './account';
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body" id="modal-body">
|
<div class="modal-body" id="modal-body">
|
||||||
<account-form [(account)]="account" (onFormChanged)="accountForm = $event"></account-form>
|
<account-form [(account)]="account" (onValid)="valid=$event"></account-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn btn-primary" [disabled]="!accountForm?.form.valid" (click)="submit()">
|
<button class="btn btn-primary" [disabled]="!valid" (click)="submit()">
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ import { Account } from './account';
|
|||||||
export class AccountEditModalComponent {
|
export class AccountEditModalComponent {
|
||||||
@Input() account: Account;
|
@Input() account: Account;
|
||||||
|
|
||||||
accountForm: NgForm;
|
valid: boolean = false;
|
||||||
|
|
||||||
constructor(public activeModal: NgbActiveModal) {}
|
constructor(public activeModal: NgbActiveModal) {}
|
||||||
|
|
||||||
|
@ -59,12 +59,12 @@ import { Account } from './account';
|
|||||||
})
|
})
|
||||||
export class AccountFormComponent implements AfterViewChecked {
|
export class AccountFormComponent implements AfterViewChecked {
|
||||||
@Input() account: Account;
|
@Input() account: Account;
|
||||||
@Output() onFormChanged: EventEmitter<NgForm> = new EventEmitter<NgForm>();
|
@Output() onValid: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||||
@ViewChild('form') form: NgForm;
|
@ViewChild('form') form: NgForm;
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
ngAfterViewChecked() {
|
ngAfterViewChecked() {
|
||||||
this.onFormChanged.emit(this.form);
|
this.onValid.emit(this.form.form.valid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user