BOOTSTRAP3 DateTimePicker Use instance _javascript techniques in Angularjs

Source: Internet
Author: User
Tags locale

About the use of DateTimePicker, reference: http://www.jb51.net/article/99896.htm

To use an instance in Angularjs:

HTML code:

<div class= "Container" ng-app= "myApp" ng-controller= "Myctrl" > <div class= "Row" > <div class= ' col-sm-6 ' & 
 Gt <div class= "Form-group" > <label> Select Date:</label> <!--specify date tag--> <div class= ' Input-group da Te ' DateTimePicker id= ' datetimepicker1 ' > <input type= ' text ' class= ' Form-control ' ng-model= ' Dateone '/> Pan class= "Input-group-addon" > <span class= "Glyphicon Glyphicon-calendar" ></span> </span> ;/div> </div> <p> Results:{{dateone}}</p> </div> <div class= ' col-sm-6 ' > <div class = "Form-group" > <label> Select Date + Time:</label> <!--specify date tag--> <div class= ' input-group date ' id= ' da Tetimepicker2 ' > <input type= ' text ' class= ' Form-control "ng-model=" Datetwo "/> <span class=" input-group-a  
 Ddon "> <span class=" Glyphicon glyphicon-calendar "></span> </span> </div> </div> <p> results: {Datetwo}}</p> </div> </div> </div> 
 

JS Code:

var app = Angular.module (' myApp ', []); 
App.controller (' Myctrl ', function ($scope) { 
 ///In Controller bind select control 
 var datepicker1 = $ (' #datetimepicker1 '). DateTimePicker ({ 
 format: ' Yyyy-mm-dd ', 
 locale:moment.locale (' ZH-CN ') 
 }). On (' Dp.change ', function (e) { 
 var result = new Moment (e.date). Format (' Yyyy-mm-dd '); 
 $scope. Dateone = result; 
 $scope. $apply (); 
 }); 
 
 $ (' #datetimepicker2 '). DateTimePicker ({ 
 format: ' yyyy mm month dd Day hh:mm ', 
 locale:moment.locale (' ZH-CN ') 
 }). On (' Dp.change ', function (e) { 
 var result = new Moment (e.date). Format (' YYYY year mm month DD Day hh:mm '); 
 $scope. datetwo= result; 
 $scope. $apply (); 
 }); 

Effect Chart:

If you want to further study, you can click here to learn, and then attach 3 wonderful topics:

Bootstrap Learning Course

Bootstrap Practical Course

Bootstrap Table Use Tutorial

Bootstrap Plugin Usage Tutorial

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.