编程语言
首页 > 编程语言> > javascript-如何动态访问ng-model名称?

javascript-如何动态访问ng-model名称?

作者:互联网

我如何在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中单击将$scope.current设置为要显示的那个.

标签:angularjs,angularjs-scope,javascript
来源: https://codeday.me/bug/20191030/1967054.html