Last active
August 10, 2021 12:55
-
-
Save maximLyakhov/a4e15784dd02a84f8bec556f8c78fa5a to your computer and use it in GitHub Desktop.
toggle inplace editing angular2+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mat-list *ngIf="contracts"> | |
<mat-list-item *ngFor="let contract of contracts"> | |
<div class="row"> | |
<span *ngIf="!contract.toggle"> | |
{{ contractFunnel.name }} | |
</span> | |
<input matInput type="text" class="input" *ngIf="contract.toggle" [(ngModel)]="contract.name"> | |
<ng-template [ngIf]="!contract.toggle" [ngIfElse]="editContract"> | |
<mat-icon *ngIf="!contract.toggle" (click)="contract.toggle = true"> | |
edit | |
</mat-icon> | |
</ng-template> | |
<ng-template #editContract> | |
<mat-icon (click)="updateContract(contract)" (click)="contract.toggle = false"> | |
done | |
</mat-icon> | |
</ng-template> | |
</div> | |
</mat-list-item> | |
</mat-list> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contracts.map(element => { | |
element.toggle = false; | |
return element | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment