gpt4 book ai didi

javascript - AngularJS展开和折叠问题

转载 作者:行者123 更新时间:2023-11-28 04:34:11 25 4
gpt4 key购买 nike

我是 angularjs 的新手,目前我正面临这个问题。

问题

当我单击任何节点时,所有节点都会展开或折叠。例如:(单击节点之前)

image1

点击节点后

enter image description here

代码

 <div class="item">Data Visualization</div>
<div class= "item">
<i class="icon ion-arrow-right-b" ng-model="collapsed" ng-click="collapsed=!collapsed"><strong> &nbsp;AGV Mileage Vs Timestamp</strong></i>
<div ng-show="collapsed">&nbsp;&nbsp;

<div id ="agvmileage">
<div class = "horizon">
<canvas width="960" height="120">
<script src="/static/js/frontend/cubi-agv.js"></script>
</div>
</div>

</div>
</div>

<div class= "item">
<i class="icon ion-arrow-right-b" ng-model="collapsed" ng-click="collapsed=!collapsed"><strong> &nbsp;Board Temperature Vs Timestamp</strong></i>
<div ng-show="collapsed">&nbsp;&nbsp;

<div id ="agvmileage">
<div class = "horizon">
<canvas width="960" height="120">
<script src="/static/js/frontend/cubi-agv.js"></script>
</div>
</div>

</div>
</div>

<div class= "item">
<i class="icon ion-arrow-right-b" ng-model="collapsed" ng-click="collapsed=!collapsed"><strong> &nbsp;Laser Sensor Output Vs Timestamp</strong></i>
<div ng-show="collapsed">&nbsp;&nbsp;

<div id ="agvmileage">
<div class = "horizon">
<canvas width="960" height="120">
<script src="/static/js/frontend/cubi-agv.js"></script>
</div>
</div>

</div>
</div>

<div class= "item">
<i class="icon ion-arrow-right-b" ng-model="collapsed" ng-click="collapsed=!collapsed"><strong> &nbsp;Battery Current Vs Timestamp</strong></i>
<div ng-show="collapsed">&nbsp;&nbsp;

<div id ="agvmileage">
<div class = "horizon">
<canvas width="960" height="120">
<script src="/static/js/frontend/cubi-agv.js"></script>
</div>
</div>

</div>
</div>

如果可能的话,我如何将“数据可视化”声明为父节点并且 其他作为子节点然后执行展开和折叠。

请赐教,提前致谢。

最佳答案

每个项目都需要有自己单独的折叠状态。例如:

项目 1

<i ng-model="collapsedMileage" ng-click="collapsedMileage = !collapsedMileage">
<strong>AGV Mileage Vs Timestamp</strong>
</i>
<div ng-show="collapsedMileage">
<!-- the rest of your template -->
</div>

第 2 项

<i ng-model="collapsedLaser" ng-click="collapsedLaser = !collapsedLaser">
<strong>Laser Sensor Output Vs Timestamp</strong>
</i>
<div ng-show="collapsedLaser ">
<!-- the rest of your template -->
</div>

第 3 项

<i ng-model="collapsedBattery" ng-click="collapsedBattery = !collapsedBattery">
<strong>Battery Current Vs Timestamp</strong>
</i>
<div ng-show="collapsedBattery">
<!-- the rest of your template -->
</div>

关于javascript - AngularJS展开和折叠问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44380616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com