http://www.lovelucy.info/angularjs-best-practices.html

http://damoqiongqiu.iteye.com/blog/1917971

http://www.itnose.net/detail/6144038.html

https://github.com/shyamseshadri/angularjs-book

2015-10-23

研究几日后,找到答案:

<!DOCTYPE html>
<html lang="en" ng-app="ProductList">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>Angularjs与bootstrap.datetimepicker结合实现日期选择器</title>
<link rel="stylesheet" href="../../assets/css/bootstrap.css" />
<link rel="stylesheet" href="../../assets/css/bootstrap-timepicker.css" type="text/css"></link>
</head> <body ng-controller="productListController">
<div class="widget-box" ng-repeat="edu in edus | filter:q as results"> <div class="form-group">
<input class="input-medium date-picker" datepicker readonly
id="id-date-picker-1" type="text" data-date-format="yyyy-mm-dd"
placeholder="" ng-model="edu.begindate" />
</div>
<button ng-click="saveEducation(edu);" >保存
</button>
<hr/>
</div>
<script src="../../assets/js/jquery.js"><!--basic样式-->
<script src="../../assets/js/bootstrap.js"></script><!--basic样式-->
<script src="../../assets/js/date-time/bootstrap-datepicker.js"></script><!-- 日期选择器必须 -->
<script src="../../frameworks/angular.min.js"></script>
<script>
var productListApp = angular.module('ProductList', []);
/*自定义指令datepicker,用于员工背景——教育经历、工作经历、家庭关系中日期数据修改时的双向绑定*/
productListApp.directive('datepicker', function() {
return {
restrict: 'A',
require: '?ngModel',
// This method needs to be defined and passed in from the
// passed in to the directive from the view controller
scope: {
select: '&' // Bind the select function we refer to the right scope
},
link: function(scope, element, attrs, ngModel) {
if (!ngModel) return;
var optionsObj = {};
console.log("directive~~~~~"+JSON.stringify( ngModel));
var updateModel = function(dateTxt) {
scope.$apply(function () {
// Call the internal AngularJS helper to
// update the two way binding
ngModel.$setViewValue(dateTxt);
});
console.log("after ngModel~~~~~"+JSON.stringify( ngModel));
}; optionsObj.onSelect = function(dateTxt, picker) {
updateModel(dateTxt);
if (scope.select) {
scope.$apply(function() {
scope.select({date: dateTxt});
});
}
}; ngModel.$render = function() {
// Use the AngularJS internal 'binding-specific' variable
element.datepicker('setDate', ngModel.$viewValue || '');
};
element.datepicker(optionsObj);
}
};
}); productListApp.controller('productListController', function($scope, $http) {
var id= 928;
//查看员工背景资料
/*$http({
method : 'POST',
url : '/omss/viewEmpBackgroudById?id='+id
}).success(function(data, status, headers, config) {
$scope.status = status;
if (data.length != 0) {
$scope.employeeBg = (data[0]);
console.log("员工背景data:"+JSON.stringify(data))
//循环多个工作经历
$scope.edus=(data[0]).eduList;
}
}).error(function(data, status, headers, config) {
$scope.data = data || "Request failed";
$scope.status = status;
$scope.tips = '对不起,您的网络情况不太稳定。';
});*/
$scope.edus=[
{
"badge": "",
"begindate": "2015-10-02",
"edutype": "3",
"enddate": "2015-10-15",
"id": "9023",
"major": "电子商务",
"schoolname": "广大",
"sid": "22F92C8D81144CDFE050007F01006C3D",
"studytype": ""
},
{
"badge": "",
"begindate": "2015-10-01",
"edutype": "3",
"enddate": "2015-10-10",
"id": "9023",
"major": "机械自动化",
"schoolname": "北大",
"sid": "23267E58D5F902D7E050007F01002EF9",
"studytype": ""
}
]; $scope.saveEducation = function(edu) {
console.log("edu.begindate........."+edu.begindate);
}
});
</script>
</body>
</html>

Angularjs与bootstrap.datetimepicker结合实现日期选择器的更多相关文章

  1. 基于bootstrap模态框的日期选择器

    近来由于工作需求,以bootstrap模态框+DIV+CSS+JS做了一个适用于移动端的日期选择器,能够满足多样的需求,目前处于第一个版本,后续可能会继续更新.废话不多说,直接进入制作过程. 首先,需 ...

  2. bootstrap datetimepicker 日期插件超详细使用方法

    日期时间选择器 目前,bootstrap有两种日历.datepicker和datetimepicker,后者是前者的拓展. Bootstrap日期和时间组件: 使用示例: 从左到右依次是十年视图.年视 ...

  3. 日期选择器(Query+bootstrap和js两种方式)

    日期选择是在下拉列表中选择年.月.日,年显示前后的五年,12个月,日就是有30.31.29.28天的区别,随着月份的变而变 一.js方式的日期选择 (1)首先就是三个下拉列表了,点击年.月.日显示列表 ...

  4. 模块:(日期选择)jquery、bootstrap实现日期下拉选择+bootstrap jquery UI自带动画的日期选择器

    一:jquery.bootstrap实现日期下拉选择 点击文本框弹出窗口 弹窗显示日期时间选择下拉 年份取当前年份的前后各5年 天数随年份和月份的变化而变化 点击保存,文本框中显示选中的日期 代码部分 ...

  5. bootstrap datetimepicker、bootstrap datepicker日期组件对范围的简单封装

    1.bootstrap datepicker 使用 <div class="row form-group"> <label class="control ...

  6. bootstrap datetimepicker 在 angular 项目中的运用

    datetimepocker 是一个日期时间选择器,bootstrap datetimepicker 是 bootstrap 日期时间表单组件.访问 bootstrap-datetimepicker  ...

  7. bootstrap datetimepicker的参数解释

    使用bootstrap datetimepicker(日期时间选择器)的过程中,发现中文参数说明和英文参数说明严重不符,所以结合自己使用的情况和英文参数说明,做了如下翻译. $(".form ...

  8. Android自己定义DataTimePicker(日期选择器)

    Android自己定义DataTimePicker(日期选择器)  笔者有一段时间没有发表关于Android的文章了,关于Android自己定义组件笔者有好几篇想跟大家分享的,后期会记录在博客中.本篇 ...

  9. 用Jquery做一个时间日期选择器

    今天我们就用Jquery做一个时间日期选择器,当打开网页时,文本框里面显示的是当前的日期,点击文本框可以出现年.月.日的下拉菜单,并且可以选择,会根据年份的选择判断是否是闰年,从而改变二月的天数,闰年 ...

随机推荐

  1. redis删除list中指定index的值

    Redis的List删除命令: lrem : lrem mylist 0 "value"    //从mylist中删除全部等值value的元素   0为全部,负值为从尾部开始. ...

  2. 安装docker管理工具rancher

    http://blog.csdn.net/freewebsys/article/details/51136562 docker(2):安装docker管理工具rancher rancher是一个Doc ...

  3. 捕获EF提交异常

    try { } catch (DbEntityValidationException dbex) { string errMsg = string.Empty; foreach (var eve in ...

  4. YII2 自定义日志路径

    YII 提供的日志写入方法: 1.Yii::getLogger()->log($message, $level, $category = 'application') 2.Yii::trace( ...

  5. Nginx负载均衡配置实例详解(转)

    负载均衡是我们大流量网站要做的一个东西,下面我来给大家介绍在Nginx服务器上进行负载均衡配置方法,希望对有需要的同学有所帮助哦. 负载均衡 先来简单了解一下什么是负载均衡,单从字面上的意思来理解就可 ...

  6. Quickling技术

    技术来自facebook,目的是实现ajax的seo友好. 简单来说就是骗爬虫,然后该写js还是写js. 原文在这里:http://www.cnblogs.com/haoming/p/3616326. ...

  7. IEnumerable 和 IEnumerator

    IEnumerable 接口只包含一个抽象的方法 GetEnumerator(),它返回一个可用于循环访问集合的 IEnumerator 对象,IEnumerator 对象是一个集合访问器. 需要给自 ...

  8. Myeclipse右键新建项目突然变的很少

    额,很是焦躁,最后在界面的右上方点Myeclipse Java enterprise变回原来模样

  9. ROS之VPN服务器设置教程.

    关于ROS系统的安装此处将不再累述,可以自行谷歌,百度搜索“ROS 安装配置教程”. (安装方法可以使用光盘安装,USB引导安装,硬盘写入.) 好了,演示创建VPN服务器的方法: 1.使用WinBox ...

  10. PHP基础 之 基本数据类型练习

    <h3>PHP基础练习</h3> <?php echo "<h4>常量</h4>"; //定义:一般大写,使用下划线间隔 de ...