Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access ng-model name dynamically?

How do I access ng-model name assigned to each div dynamically in for loop in function which I'm calling on ng-click?

I've four divs in my page and at a time i want to display only one and hide others. I'm trying to do this using 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>
like image 503
Pranalee Avatar asked Feb 18 '26 12:02

Pranalee


1 Answers

try:

<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>

and in ng-click set $scope.current to the one you want to show.

like image 152
Attila Miklosi Avatar answered Feb 21 '26 02:02

Attila Miklosi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!