1

I'm looking for angular-way solution for task:

Imagine, we have many rows like

<tr>
<td>
 <span>click me</span>
 <span style='display: none;'>i'll be shown</span>
</td>
</tr>
...[a lot as the same rows]...

All i want is to show second span and hide first, after click to first span.

p.s. really don't want to use jQuery for this issue.

1 Answer 1

2

In the view:

<span ng-click="onItemClicked(currentItem)">click me</span>
<span ng-show="currentItem.isVisible">I'll be shown</span>

And in the controller:

  $scope.onItemClicked = function (item) {
    item.isVisible = true;
  };

Read the documentation about ngShow.

Working demo: http://plnkr.co/edit/FEZ5JDfVfeWKSGOHjBSy?p=preview

Sign up to request clarification or add additional context in comments.

2 Comments

but he needs to hide the first span
to hide the first element you can add ng-hide <span ng-hide="currentItem.isVisible" ng-click="onItemClicked(currentItem)">click me</span>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.