简体   繁体   English

如何根据点击在Angular js中的ng-repeat中给手风琴?

[英]How to give accordion in ng-repeat in angular js according to click?

In this code when I am clicking on span ng-click="click_subcat(opp.ct_nm); it is loading the content in <span ng-click="click_pdms(opp.sbct_nm);" style="color:white;cursor:pointer">{{opp.sbct_nm}}</span> .But problem is that when I am clicking i=on that span all are loading in <span ng-click="click_pdms(opp.sbct_nm);" style="color:white;cursor:pointer">{{opp.sbct_nm}}</span> 在这段代码中,当我单击span ng-click="click_subcat(opp.ct_nm);它将内容加载到<span ng-click="click_pdms(opp.sbct_nm);" style="color:white;cursor:pointer">{{opp.sbct_nm}}</span> 。但是问题是,当我单击i = on时,该跨度全部加载到<span ng-click="click_pdms(opp.sbct_nm);" style="color:white;cursor:pointer">{{opp.sbct_nm}}</span>

Here I the code (Before Click). 这是我的代码(单击前)。 在此处输入图片说明 (After Click) In Every category it is loading the same.And I want in electronics it will load laptop and mobile not in fashion. (单击后)在每个类别中加载相同。我想在电子产品中加载笔记本电脑和移动设备时不流行。 在此处输入图片说明

<div id="mySidenav" class="sidenav" >
                <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
                <!--<a ng-click="click_subcat(opp.ct_nm);">{{opp.ct_nm}}</a>-->
                <a ng-repeat="opp in res">
                    <span ng-click="click_subcat(opp.ct_nm);" style="color:white;cursor:pointer;font-size:60px;" class="accordion">
                        {{opp.ct_nm}}

                        <ul ng-repeat="opp in inp">
                            <li>
                                <span ng-click="click_pdms(opp.sbct_nm);" style="color:white;cursor:pointer">{{opp.sbct_nm}}</span>
                            </li>
                        </ul>
                    </span>
                </a>
            </div>

Just added another $scope.hiddenDiv = [] so that it will show the div according to the index of that main $scope index. 刚刚添加了另一个$ scope.hiddenDiv = [],以便它将根据该主要$ scope索引的索引显示div。

$scope.click_subcat = function (btnval,index)
    {
        var responsed;
        $scope.hiddenDiv = [];
        var urlg = 'http://localhost/Publish/ProductSubCategory/GET?sbct=' + btnval;
        $http.get(urlg).then(function (responsed)
        {

            $scope.hiddenDiv[index] = !$scope.hiddenDiv[index];
            $scope.inp = responsed.data;
        });
    };

and Added another div to make it visible true and false. 并添加了另一个div以使其显示为true和false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM