GithubHelp home page GithubHelp logo

angular-filter-pack's Introduction

AngularJS Filter Pack

Filter Pack for AngularJS

AngularJS filters are awesome and convenient.

Unfortunately AngularJS only contains a few basic filters.

This filter pack conveniently provides your AngularJS application with an additional set of filters.

Lightweight and tested.

Installation

Install via bower:

$ bower install angular-filter-pack

Then include the module in your AngularJS app:

angular.module('yourApp', ['angularFilterPack']);

Filters

Trim

Trims a string:

  • lowercases the string
  • replaces whitespace a dash

Signature: trim(input [,characters])

  • input: string (in a view template this is the piped expression)
  • characters: characters to trim, defaults to whitespace

In a view template:

{{ ' hello world ' | trim }}
{{ '-hello world-' | trim:'-' }}

In JavaScript code:

angular.controller('someCtrl', ['slugifyFilter', function(slugify){

    slugify('Hello world'); // hello-world
    slugify('Hello World'); // hello-world
    slugify('HelloWorld'); // helloworld
    slugify('Hello_World'); // hello-world

}]);

Slugify

Slugifies a string:

  • lowercases the string
  • replaces whitespace a dash

Signature: slugify(input)

  • input: string (in a view template this is the piped expression)

In a view template:

{{ 'hello world' | slugify }}

In JavaScript code:

angular.controller('someCtrl', ['slugifyFilter', function(slugify){

    slugify('Hello world'); // hello-world
    slugify('Hello World'); // hello-world
    slugify('HelloWorld'); // helloworld
    slugify('Hello_World'); // hello-world

}]);

Dasherize

Dasherizes a string:

  • lowercases the string
  • replaces whitespace with dash
  • replaces underscores with dash
  • leaves existing dashes untouched
  • replaces capitals with dash and lowercase

Signature: dasherize(input)

  • input: string (in a view template this is the piped expression)

In a view template:

{{ 'hello world' | dasherize }}

In JavaScript code:

angular.controller('someCtrl', ['dasherizeFilter', function(dasherize){

    dasherize('Hello world'); // hello-world
    dasherize('Hello World'); // hello-world
    dasherize('HelloWorld'); // hello-world

}]);

Change log

v0.2.0

  • Added dasherize filter
  • Added trim filter

v0.1.0

  • Added slugify filter
  • Initial version

angular-filter-pack's People

Contributors

jvandemo avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.