I have an ng-repeat directive where i show all the objects (ideas). If an idea description (string) is longer than x, i want to display only the first x charachters and a "show all" link. User can click on this link, and the whole text will be displayed. But only one idea at a time can be displayed with its whole text.
I have this for now:
div(ng-show = "idea.description.length > maxIdeaDescLength && openLongIdea != idea._id")
i {{idea.description.substring(0, maxIdeaDescLength) }} ...
a(href='', ng-click='openLongIdea = idea._id') show all
div(ng-show = "idea.description.length <= maxIdeaDescLength || openLongIdea == idea._id")
i {{idea.description}}
This is a part of my controller:
$scope.openLongIdea = 0;
So when i click on the show all link, the ideaID will be saved to the variable openLongIdea. And because of my ng-show conditions i expect to display whole description only when idea-ID matches with openLongIdea-ID. But i still see more than one ideas with their long descriptions at a time.
First time when the ideas are displayed, my logic works. When i click on a show all link, the longer text will be displayed. But when i click the see all link of another idea, it will also be displayed as a whole beside the old idea, although i overwrite the value in openLongIdea with the new Idea-ID.
What is the problem here?