I'm facing difficulties in Angular UI development. Here I'm having a requirement that:
- on click of Add Button it should show a hidden form:
- on click of Add Button -> Add Button should hide
- in hidden form there will be a button Cancel-
- if I click on cancel the form should hide and add button should return
I have tried this using Angular 2 template syntax and by declaring nested boolean values, but I'm not getting the perfect answer.
How to do this in Angular 2 or 4? Do I have to use any host Listener or event emitter for this? I'm sharing my sample code and plunker:
template.html
<button(click)="addParameter=addParameter==true?false:true">
Add</button>
<div class="Parameters" *ngIf="addParameter==true">
<input name="hello">
<button (click)="hideForm();">Cancel</button>
</div>
test.ts
export class App {
private addParameter:boolean=false;
}