如果我每次都重新加载页面,我想点击一次ng-click,禁用ng-click。我怎样才能做到这一点?
我点击的代码 注意:这是一个自定义过滤器,它是在点击中构建的,并且在它的样式后也有一个ngclass。
a class =“clear-completed”ng-click =“taskfilter ='todo'; infoTitel ='To do'”ng-class =“{'active':taskfilter =='todo'}”---这条线需要在默认情况下点击。
<div style="display: block;" class="task-footer">
<!-- <a id="clear-completed" ng-click="clear()" ng-show="hasDone()">
Clear <span >{{(tasks.length - remaining())}} {{itemText()}}</span>.
</a> -->
<div class="mini-nav">
<a class="clear-completed" ng-click="taskfilter = 'missed'; infoTitel = 'Deadline missed'" ng-class="{'active' : taskfilter == 'missed'}">
<span>deadline missed</span>
</a>
<a class="clear-completed" ng-click="taskfilter = 'all'; infoTitel = 'All'" ng-class="{'active' : taskfilter == 'all'}">
<span>show all </span>
</a>
<a class="clear-completed" ng-click="taskfilter = 'completed'; infoTitel = 'Completed'" ng-class="{'active' : taskfilter == 'completed'}">
<span>show completed</span>
</a>
<a class="clear-completed" ng-click="taskfilter = 'todo'; infoTitel = 'To do'" ng-class="{'active' : taskfilter == 'todo'}" ng-init="">
<span>to do</span>
</a>
</div>
<div class="todo-count">{{remaining()}} of {{tasks.length}} remaining</div>
<div class="todayDate"> Date today : {{ todayDate | date : "MMM d, y h:mm a"}}</div>
</div>
答案 0 :(得分:0)
我已经知道了你可以在同一规则上将所希望的ng-click的值设置为ng-init,这样就可以在加载时选择它。
<a class="clear-completed" ng-click="taskfilter = 'todo'; infoTitel = 'To do'" ng-class="{'active' : taskfilter == 'todo'}" ng-init="taskfilter = 'todo'; infoTitel = 'To do'">