我想通过下拉菜单创建角度药丸。 我已经实现了这一点,但问题是只有跨度或可点击而不是药丸的其余部分。 然而,如果我点击药丸它仍然高亮药丸,但没有完成它点击它时必须做的任务。如何实现全部范围是可点击的,而不仅仅是文本。
以下是我的代码:
<div data-tabset="" type="pills">
<div style="height: 80px" data-tab="" data-active="item.active" data-ng-repeat="item in items" data-ng-if="(item.Processes.length >= 1)">
<div data-tab-heading="">
<span style="height: 80px" class="dropdown" ng-if="(item.Processes.length > 1)">
<span class="dropdown-toggle">
{{item.Name}}
</span>
<ul class="dropdown-menu">
<li ng-repeat="proc in item.Processes">
<a dropdown-toggle ng-click="Function2(item.ID,proc.UniqueID)">{{proc.Description}}</a>
</li>
<li>
<a dropdown-toggle ng-click="Function1(item.ID,-1)">all</a>
</li>
</ul>
</span>
<span style="height: 80px" ng-if="(item.Processes.length == 1)" ng-click="Function1(item.ID,item.proc.UniqueID)">{{item.Name}}</span>
</div>
</div>
</div>
答案 0 :(得分:-1)
通过在所有跨度上添加一个函数来解决它,检查选择了什么值并取消选择全部并选择该值。现在不是点击工作,但至少现在没有选择错误的点击。
HTML:
<div data-tabset="" type="pills">
<div data-ng-if="(subsidiaries.length == 0)"><h2>U heeft geen werkmaatschappijen om te tonen</h2></div>
<div style="height: 80px" data-tab="" data-active="sub.active" data-ng-repeat="sub in subsidiaries" data-ng-click="setPillSelected()" data-ng-if="(sub.Processes.length >= 1)">
<div data-tab-heading="">
<span style="height: 80px" class="dropdown" dropdown ng-if="(sub.Processes.length > 1)">
<span class="dropdown-toggle" dropdown-toggle>
{{sub.Name}}
</span>
<ul class="dropdown-menu">
<li ng-repeat="proc in sub.Processes">
<a ng-click="generateFunnelData(sub.SubsidiaryID,proc.SubsidiaryProcessID, true)">{{proc.Description}}</a>
</li>
<li>
<a ng-click="generateFunnelData(sub.SubsidiaryID,-1, true)">alles</a>
</li>
</ul>
</span>
<span style="height: 80px" ng-if="(sub.Processes.length == 1)" ng-click="generateFunnelData(sub.SubsidiaryID,sub.proc.SubsidiaryProcessID, true)">{{sub.Name}}</span>
</div>
</div>
</div>
javascript方:
setPillSelected: function () {
var self = this;
self.$.subsidiaries.forEach(function(subsidiary) {
if (subsidiary.SubsidiaryID == self.$.subsidiary.SubsidiaryID) {
subsidiary.active = true;
} else {
subsidiary.active = false;
}
});
},
我希望它可以帮助其他人