Remove angular limitTo on ng-click

So, I have a list of messages, and they are all different lengths, so I cut them off at the 500th character, but I want to show the rest of the message on ng-click . There seems to be some kind of “angular way” for this, but I haven't found it through google.

 <ul id = "postsList"> <li ng-repeat="post in Posts" > <p>{{ post.messageBody | limitTo:500 }}</p> <button ng-click = "undoLimitTo()">View</button> </li> </ul> 
+6
source share
2 answers

I would write this as:

set the editable value for the limit and give Posts length

 <ul id = "postsList"> <li ng-repeat="post in Posts" ng-init="limit= 500"> <p>{{ post.messageBody | limitTo:limit }}</p> <button ng-click = "limit = Posts.length">View</button> </li> </ul> 
+11
source

Try the following:

 <ul id = "postsList" ng-init="limit = 500"> <li ng-repeat="post in Posts" > <p>{{ post.messageBody | limitTo:limit }}</p> <button ng-click = "limit = Number.MAX_SAFE_INTEGER">View</button> </li> </ul> 

EDIT

That shit. It will change the limit for all messages.

In the controller, you can add the limit property to Posts . And then:

 <ul id = "postsList"> <li ng-repeat="post in Posts" > <p>{{ post.messageBody | limitTo:post.limit }}</p> <button ng-click = "post.limit = post.messageBody.length">View</button> </li> </ul> 
+3
source

All Articles