fix form value not changed when inputs change
This commit is contained in:
parent
8131705558
commit
d3d322d444
@ -15,7 +15,7 @@
|
||||
<ng-container *ngIf="editing">
|
||||
<form (submit)="saveValue()">
|
||||
<div [class]="'iqser-input-group ' + class">
|
||||
<input [(ngModel)]="newValue" [placeholder]="placeholder" name="name" />
|
||||
<input (ngModelChange)="newValue = $event" [ngModel]="value" [placeholder]="placeholder" name="name" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, HostBinding, Input, Output } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, HostBinding, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
||||
import { Required } from '../../utils';
|
||||
import { CircleButtonType } from '../../buttons';
|
||||
|
||||
@ -8,7 +8,7 @@ import { CircleButtonType } from '../../buttons';
|
||||
styleUrls: ['./editable-input.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class EditableInputComponent {
|
||||
export class EditableInputComponent implements OnChanges {
|
||||
@Input() @Required() value!: string;
|
||||
@Input() editTooltip?: string;
|
||||
@Input() saveTooltip?: string;
|
||||
@ -32,6 +32,12 @@ export class EditableInputComponent {
|
||||
this.newValue = this.value;
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes.value) {
|
||||
this.editing = false;
|
||||
}
|
||||
}
|
||||
|
||||
saveValue(): void {
|
||||
this.save.emit(this.newValue);
|
||||
this.editing = false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user