2016-02-05 29 views

回答

1

您不能添加或使用方芯的指令刪除任何屬性,你可以做類似下面。我想你不想有條件地致電vm.addFilter()

<a ng-click="toggle && vm.addFilter()">Add Policy</a> 

How && works in depth?

@deceze具有良好的點,有沒有需要展示元素,除非它做一些動作。根據這一點,你也可以使用ng-if作爲@Serginho在他的回答中提出的隱藏/刪除元素。

+0

謝謝你,這是我想要的 – Decastrio

2

你想這樣做嗎?

//If you want to hide the element use this 
<a ng-if="toggle" ng-click="vm.addFilter()" >Add Policy</a> 

或本

//If you want to avoid the event with toggle variable 
<a ng-click="toggle && vm.addFilter()" >Add Policy</a> 
+0

是的,第二個 – Decastrio

+1

@Decastrio不,你想要第一個。 – deceze

+0

@deceze,第二個= D – Decastrio