Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
How to close the popup modal when we click on save or cancel button

I have an angular application, In that I have created the popover using angular.

.component.html

 <div class="col-md-4 ">
          <div class="cc button-popover" >
          <popover-content #addObjectivePopovers
          [animation]="true"
          [closeOnClickOutside]="false"
          [closeOnMouseOutside]="false" class="vb" *ngIf="!showPopover" >

    <form >
          <div class="form-group popover-form" >
              <label>Enter Custom Trigger Habit: When I</label>
              <textarea class="form-control" [(ngModel)]="name" name="name"></textarea>
              
          </div><br>
            <div class="form-group popover-form">
              <label>Enter Custom Trigger Habit: I will</label>
              <textarea class="form-control" #customHabit id="power" maxlength="1500" [(ngModel)]="name2" name="name2"></textarea>
              <p class="textarea-count">({{1500 - customHabit.value.length }} of 1500 Characters remaining)</p>
            </div>
            <div class="popover-btn">
              <button  class="btn btn-default " (click)="showPopover = false">CANCEL</button>
              <button type="button" (click)="save()" >SAVE</button>
            </div>
      </form>
</popover-content>
</div>

<button [popoverOnHover]="false" type="button" popoverPlacement="bottom"   [popover]="addObjectivePopovers" >ADD CUSTOM HABIT</button>
        </div>

So when I add some content in textarea and click on the save button I has to close the popup ,and also when we click on the cancel also It should close the popup.

Can anyone help on the same.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Assuming the show boolean flag is separate from the visible state of the popover then add a new boolean flag to your component ts which will be used to manage the visible state of the popover and toggle it with your cancel/save controls:

component ts:

showPopover = false

save() {
  this.show = true;
  this.showPopover = false;
}

component html:

<div class="form-group popover-form" *ngIf="showPopover">
    <textarea class="form-control" id="power" maxlength="1500" [(ngModel)]="name" name="name"></textarea>
</div>

<div>
    <button  class="btn btn-default cancel-btn" (click)="showPopover = false">CANCEL</button>
    <button type="button" (click)="save()">SAVE</button>
</div>

<p *ngIf="show">{{name}}</p>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!