Click Button to show another button and opposite

Issue

I am wanting to have the Resolve Ticket Button showing when the open item is an Incident. When I click Resolve Ticket, I want Cancel and Confirm buttons to show. However, when you click Cancel I need Resolve Ticket to show again. I can get Cancel/Confirm to show, but clicking Cancel does nothing. The HTML is below.

<div class="panel b" ng-if="c.data.isIncident == true"> 
         <div class="panel-heading bg-primary"> 
             <div class="panel-title">Is this no longer an issue?</div> 
         </div> 
         <div class="panel-body"> 
        <div ng-if="!c.data.isDialogOpen"> 
         <a class="btn btn-primary" ng click="c.openConfirmDialog()">Resolve Ticket</a> 
 </div> 
<div ng-if="c.data.isDialogOpen">
<a class="btn btn-primary" ng-click="!c.openConfirmDialog()">Cancel</a>
<a class="btn btn-primary" ng-click="c.openConfirmDialog()">Confirm</a>
 </div>
</div>
</div>

The AngularJS function is

function($location) {
/*widget conotroller */
var c = this; 
c.data.isIncident = false
if ($location.search().table == 'incident'){
c.data.isIncident = true 
}
c.openConfirmDialog = function(){
    c.data.isDialogOpen = true; 
}
}

Solution

Try this:

<a class="btn btn-primary" ng-click="c.data.isDialogOpen = false; c.data.isIncident = true">Cancel</a>

I’m not sure what you were trying to do with !c.openConfirmDialog() but this will definitely not undo what the function did when it was called before.

Answered By – Titus

Answer Checked By – Senaida (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.