如何在我在 ng-click 上调用的函数中的 for 循环中动态访问分配给每个 div 的 ng-model 名称?
我的页面中有四个 div,一次我只想显示一个并隐藏其他的。 我正在尝试使用 ng-show 来做到这一点。
<div ng-show="content0">content0 details here...</div>
<div ng-show="content1">content1 details here... </div>
<div ng-show="content2">content2 details here...</div>
<div ng-show="content3">content3 details here... </div>
最佳答案
尝试:
<div ng-show="current == 0">content0 details here...</div>
<div ng-show="current == 1">content1 details here... </div>
<div ng-show="current == 2">content2 details here...</div>
<div ng-show="current == 3">content3 details here... </div>
并在 ng-click 中将 $scope.current 设置为您要显示的那个。
关于javascript - 如何动态访问 ng-model 名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19274079/