Tagged: angularjs limitto in controller

SET Limit length of a string truncate filter with AngularJS 0

SET Limit length of a string truncate filter with AngularJS

SET Limit length of a string truncate filter with AngularJS

In this Post We Will Explain About is SET Limit length of a string truncate filter with AngularJS With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Truncate text with angular-truncate filter Example

In this post we will show you Best way to implement Limit the length of a string with AngularJS, hear for angular-truncate – AngularJS Modules, Plugins and Directives with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

AngularJS Truncate String Filter Example

In this Example,First of all Add or Include External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priority set.After that Include your relevant CSS Class.

angular-truncate simple filter is an best way to filter for AngularJS to any data truncate strings to a total set number of specify characters or some words and create ellipses when some needed.

Include External Libs

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
</head>

index.html

<body>
<h1></h1>
<!-- Devloped by Pakainfo.com free download examples -->
  <div ng-app="liveApp">
      <h1>Example of the AngularJS Truncate String Filter</h1>
      <p>This very simple light filter some truncate strings if their change lenth is superior and than the simple any number you specify.</p>
	  <!-- Devloped by Pakainfo.com free download examples -->
      <ul ng-controller="websiteCtrl">
        <li ng-repeat="wb in webs">{{ wb | truncate:true:15:' ...' }}</li>
      </ul>
  </div>
</body>
  

index.js

var liveApp = angular.module('liveApp', []);

liveApp.filter('truncate', function () {
    return function (total_val, changword, max, tail) {
        if (!total_val) return '';
        max = parseInt(max, 10);
        if (!max) return total_val;
        if (total_val.length <= max) return total_val;

        total_val = total_val.substr(0, max);
        if (changword) {
            var space_last = total_val.lastIndexOf(' ');
            if (space_last != -1) {
                total_val = total_val.substr(0, space_last);
            }
        }
        return total_val + (tail || ' …');
    };
});

liveApp.controller('websiteCtrl', function($scope) {
  $scope.webs = ['Welcome to Pakainfo.com', 'Live24u my website', 'Free download live24u', 'angularjs Free Example', 'vuejs live example', 'jaydeep gondaliya']
})

style.css

/* Buddyweb standard style */

@import url('https://fonts.googleapis.com/css?family=Rubik');
body {
  padding: 6em 6em;
  font-family: 'Rubik', sans-serif;
  background-color: #3D3D3D;
}

Truncate Filter for AngularJS

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is angular-truncate – AngularJS Modules, Plugins and Directives And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.