我在我的angularjs項目引導手風琴中使用。項目擴展時如何觸發事件?
這裏工作plunker
當我展開的手風琴我想火在我的名爲fireOnExpand
控制器功能,並通過該組的適當Id
的功能。
這是我如何用手風琴:從控制器
<div ng-controller="MainCtrl">
<uib-accordion>
<uib-accordion-group heading="{{group.title}}" ng-repeat="group in groups" ng-init="isOpen = $first" is-open="isOpen">
<uib-accordion-heading>
<span ng-click="fireOnExpand()"></span>
<div class="text-center text-info">
<strong>{{group.title}}</strong>
</div>
</uib-accordion-heading>
{{group.content}} {{test}}
</uib-accordion-group>
</uib-accordion>
以下是項目所顯示:
$scope.groups = [
{Id: 5, title: "Dynamic-1", content: "Dynamic Group Body - 1"},
{Id: 8, title: "Dynamic-2", content: "Dynamic Group Body - 2"},
{Id: 1, title: "Dynamic-3", content: "Dynamic Group Body - 3"},
{Id: 3, title: "Dynamic-4", content: "Dynamic Group Body - 4"}];
這裏的功能控制器,我不會火上展開:
$scope.fireOnExpand = function()
{
alert("ParamPamPam");
};
例如:
如果擴展了標題文本「Dynamic-2」的手風琴項目,我希望觸發fireOnExpand
事件處理程序並將事件傳遞給適當的Id(即, ID = 8)。
當手風琴項目被展開時,我應如何觸發功能fireOnExpand
並通過適當的Id
參數?
帕萬感謝您的答案,很酷!當第一個項目展開後,有沒有什麼辦法可以啓動fireOnExpand函數? – Michael
你在尋找這個https://plnkr.co/edit/RLCQ0ALXZS8ufek3bTwv?p=preview –