Prev Demo
AngularJS
>
Limit Characters
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <div ng-app="app" ng-controller="LimitController"> <h4>String limit</h4> <p>{{ 'TechFunda' | limitTo:4}}</p> <h4>Dynamic string limit</h4> <p>Example string: <b>{{Characters}}</b> <br />Limit characters to : <input type="number" ng-model="CharactersLimit" /> => {{ Characters | limitTo:CharactersLimit}} </p> <h4>String Array limit</h4> <p> Example Array: <b>{{CharactersArray}}</b> <br />Limit array element to : <input type="number" ng-model="CharactersLimitA" /> => {{ CharactersArray | limitTo:CharactersLimitA}} </p> </div> <script> var app = angular.module("app", []); app.controller("LimitController", ["$scope", function($scope){ $scope.Characters = "Tech Funda is how to tutorials website." ; $scope.CharactersLimit = 10; $scope.CharactersArray = ['Tech','Funda','is','how','to','tutorials','website.']; $scope.CharactersLimitA = 3; }]); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output