Coder Social home page Coder Social logo

angular-filters's Introduction

#Angular Filters

Create some custom filters using Angular.

##Proper Case

Create a filter called capitalize that translates a string to proper case. This means each word has only the first character capitalized. Also, make sure this filter doesn't break with blank/undefined input.

###Usage example

{{name | capitalize}}

###Example Input and Output

Input: jane doe
Outputs: Jane Doe

Input: MiSSiSSiPPi
Output Mississippi

Input: the quick brown FOX!!
Output: The Quick Brown Fox!!

##Ordinal

Create a filter called ordinal that takes a number and outputs the number with the proper ordinal suffix (1st, 2nd, 3rd, 4th, 5th, ...). If the filter receives something that is not a number it should just return that input unmodified.

###Usage example

{{number | ordinal}}

###Example Input and Output

Input: 1
Output: 1st

Input: 453
Output: 453rd

Input: 5000
Output: 5000th

Input: taco
Output: taco

Hint: Generally you only have to look at the last digit, BUT don't forget that the teens are different (11th, 12th, 13th, 113th, etc.)

##Swear Filter

Sometimes your site needs to be G or PG. Create a filter called swearfilter that censors bad words by replacing the word with asterisks. You could also add options to leave the first letter, in case your viewers want some context for the word. For example:

Input: homework
Output: ********

Input: timely
Output: t*****

angular-filters's People

Watchers

James Cloos avatar Katlyn 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.