javascript - Show last few characters when data binding in angularjs -
i understand how data binding works in simple example, i'm curious on how limit output display last 4 characters of whatever number put in, instead of entire number:
<!doctype html> <html ng-app> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body> <div> <label>name:</label> <input type="text" ng-model="number" placeholder="enter long number here"> <hr> <h1>hello {{number}}!</h1> </div> </body> </html>
how go doing this?
from angularjs limitto docs do:
<h1>hello {{number | limitto: -4}}!</h1>
or see plunkr more options.
Comments
Post a Comment