A brief analysis of the $filter service of the angular of angular learning notes _angularjs

Source: Internet
Author: User

First, introduce the next $filter service:

1, $filter is used for data format of the special services;

2, Angularjs built-in currency, date, filter, JSON, LimitTo, lowercase, uppercase, number, by the 8 filter;

3, filter can be nested use, with the pipe symbol "|" To separate (a bit like Linux);

4, filter can pass parameters;

5, user can customize filter.

Introduction to the built-in filter:

Currency: Used to format money, such as "$" or "¥" before a value.

Date: formats dates, which provide a rich date format.

JSON: Complete JSON formatting.

Number: such as turning into two decimal places.

ORDER BY: Sort.

Simple use of filter:

{{1304375948024 | date}}
{{1304375948024 | date: ' MM/DD/YYYY H:mma '}}
{{1304375948024 | date: ' YYYY-MM-DD hh:mm:ss '}}
{| currency}}

Output:

May 3, 2011
05/03/2011 6:39am
2011-05-03 06:39:08
$30.00

Custom filter:

eg

var mymodule = angular.module (' MyModule ', []);
Mymodule.filter (' Myfilter ', function () {return
function (item) {return
' Hi, ' +item
}} '
);

Using: {{' Jennylin ' | myfilter}}

The above content more detailed to introduce the angular of the $filter service, I hope to help you, if you have any questions welcome to my message, small series will promptly reply to everyone!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.