Angularjs Date Format detailed _angularjs

Source: Internet
Author: User


Angularjs is designed to overcome the lack of HTML in building applications. HTML is a good declarative language for static text presentation, but it is weak to build a Web application. So I did some work (you can also think of it as a gimmick) to get the browser to do what I want.



Angularjs date format has two forms, one is in the HTML page, one is in the JS code, are used to Angularjs filter $filter.



Html:date_expression is the date type variable you set up in $scope (note that it must be date object to be correct), and also to be displayed, | is the split symbol, the first argument after the split symbol date is the filter type that indicates the filter date. , the second parameter format is what you want to format in your date, such as YYYY-MM-DD, the last timezone is the time zone (optional parameter), for the internationalization of the site is more appropriate.





 code as follows:

{{date_expression | date:format:timezone}}





Two ways: You can use the {{}} expression, or you can use Ng-bind or Ng-model





code as follows:

{{mydate | date: ' Medium '}}


 code as follows:

var myjsdate= $filter (' Date ') ($scope. MyDate, ' yyyy-mm-dd ');





So the variable myjsdate you declare will get the value of MyDate formatted in $scope.



The above content is small make up for everyone to share the Angularjs date format of all the narrative, I hope you like.


Related Article

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.