Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angularjs left xx characters

angular.module('ng').filter('cut', function () {
        return function (value, wordwise, max, tail) {
            if (!value) return '';

            max = parseInt(max, 10);
            if (!max) return value;
            if (value.length <= max) return value;

            value = value.substr(0, max);
            if (wordwise) {
                var lastspace = value.lastIndexOf(' ');
                if (lastspace !== -1) {
                  //Also remove . and , so its gives a cleaner result.
                  if (value.charAt(lastspace-1) === '.' || value.charAt(lastspace-1) === ',') {
                    lastspace = lastspace - 1;
                  }
                  value = value.substr(0, lastspace);
                }
            }

            return value + (tail || ' …');
        };
    });
Comment

PREVIOUS NEXT
Code Example
Javascript :: check date clash js 
Javascript :: ExoPlayer with auto linking react native 
Javascript :: json url data is not showing in console using jquery 
Javascript :: validator.addmethod username duplicates 
Javascript :: apache log format json 
Javascript :: what is the modern syntax for iterating through array using for loop in javascript 
Javascript :: multiple set in meteor user 
Javascript :: conditional rendering alert if input fields are empty 
Javascript :: discord js get badge user 
Javascript :: how to transpose json data 
Javascript :: javascript function with condition in parameter 
Javascript :: sumoselect select all option 
Javascript :: Send redirect URL in the text body of mail using nodemailer 
Javascript :: mindfusion calendar 
Javascript :: mongodb hasOwnProperty returns false 
Javascript :: set in Dynamo DB not properly incrementing nodejs lamnda function 
Javascript :: which node primary pacemaker of heart 
Javascript :: adding growl delete notifications in vanilla js 
Javascript :: 3. What are private member variables. in js 
Javascript :: show object unordered in chrome console 
Javascript :: react native add two view 
Javascript :: how to create alias in populate moongoose + nodejs 
Javascript :: angularjs fractionSize with dot 
Javascript :: firebase angular send notification to by tocken 
Javascript :: openseamap nodejs github 
Javascript :: how to make a rectangle in matter.js 
Javascript :: javascript linkify string text 
Javascript :: trigger click on each element of class 
Javascript :: initialization failed for block pool registering (datanode uuid unassigned) service to exiting 
Javascript :: traduire text with api translate google in react 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =