单击按钮以显示另一个按钮,然后相反

时间:2018-04-21 14:56:36

标签: javascript angularjs angularjs-ng-click angular-ng-if servicenow

我希望在打开的项目是事件时显示Resolve Ticket按钮。当我单击Resolve Ticket时,我想要显示Cancel和Confirm按钮。但是,当您单击取消时,我需要解决故障单再次显示。我可以显示取消/确认,但单击取消不会执行任何操作。 HTML在下面。

<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>

AngularJS功能

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; 
}
}

1 个答案:

答案 0 :(得分:0)

试试这个:

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

我不确定你试图用!c.openConfirmDialog()做什么,但这肯定不会撤消该函数在之前被调用时所做的事情。