angular.js的时间指令
最后样式

html
.input-group(style="max-width:150px")
input.form-control(uib-datepicker-popup="{{format}}" ng-model="dt" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="关闭" current-text="今天" alt-input-formats="altInputFormats" clear-text='清除')
span.input-group-btn
span.btn.btn-default(ng-click="open()")
i.glyphicon.glyphicon-calendar
js
angular.module("app")
.directive('timePicker', ["$rootScope", function($rootScope) {
// Runs during compile
return {
scope: {
dt: "=model" //显示列表头部th信息,及绑定的内容
}, // {} = isolate, true = child, false/undefined = no change
controller: ["$scope", "$element", "$attrs", "$transclude", function($scope, $element, $attrs, $transclude) {
// console.log($scope);
$scope.today = function() {
$scope.dt = new Date();
};
if(!$scope.dt){
// $scope.today();
}
// $scope.inlineOptions = {
// customClass: getDayClass,
// minDate: new Date(),
// showWeeks: true
// };
$scope.dateOptions = {
//dateDisabled: true,
formatYear: 'yy',
//maxDate: new Date(2020, 5, 22),
//minDate: new Date(),
startingDay: 1,
formatDayHeader:'EEE',
showWeeks:false
};
$scope.open = function() {
$scope.popup1.opened = true;
};
$scope.setDate = function(year, month, day) {
$scope.dt = new Date(year, month, day);
};
$scope.format = 'yyyy-MM-dd';
$scope.altInputFormats = ['M!/d!/yyyy'];
$scope.popup1 = {
opened: false
};
$scope.popup2 = {
opened: false
};
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
var afterTomorrow = new Date();
afterTomorrow.setDate(tomorrow.getDate() + 1);
$scope.events = [
{
date: tomorrow,
status: 'full'
},
{
date: afterTomorrow,
status: 'partially'
}
];
function getDayClass(data) {
var date = data.date,
mode = data.mode;
if (mode === 'day') {
var dayToCheck = new Date(date).setHours(0,0,0,0);
for (var i = 0; i < $scope.events.length; i++) {
var currentDay = new Date($scope.events[i].date).setHours(0,0,0,0);
if (dayToCheck === currentDay) {
return $scope.events[i].status;
}
}
}
return '';
}
}],
// require: 'ngModel', // Array = multiple requires, ? = optional, ^ = check parent elements
restrict: 'AE', // E = Eleme nt, A = Attribute, C = Class, M = Comment
// template: '',
templateUrl: 'app/dist/directive/timepicker/date.html',
// replace: true,
//transclude: true,
link: function(scope, element, c, d, transclude) {
// console.log(scope)
// scope.Fn=scope.Fn&&scope.Fn(scope)||{};
}
};
}]);
angular.js的时间指令的更多相关文章
- 推荐 15 个 Angular.js 应用扩展指令(参考应用)
几天前我们看到Angular 1.4.0发布了-一个以社团为驱动的发布版本涵盖了400多个GitHub的提交,增加了对特性的提升,比如动画,以及可用性. 官方新闻发布稿 覆盖了绝大部分,这同样值得放于 ...
- Angular JS学习之指令
1.Angular JS通过称为指令的新属性来扩展HTML:通过内置的指令来为应用添加功能: 2.AngularJS指令:AngularJS指令是扩展的HTML属性,带有前缀ng-: **ng-app ...
- Angular.js之自定义指令学习笔记
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- angular.js的ng-app 指令定义一个 AngularJS 应用程序。
<!DOCTYPE html> <html lang="en" ng-app> <head> <meta charset="UT ...
- angular.js的表格指令
html div.col-sm-12 table.table.table-bordered.table-condensed.table-hover.table-striped.dataTable.no ...
- angular.js创建自定义指令-demo3
html: <!doctype html><html ng-app="myModule"> <head> <meta charset=&q ...
- Angular JS中$timeout的用法及其与window.setTimeout的区别
$timeout的用法 angular.js的$timeout指令对window.setTimeout做了一个封装,它的返回值是一个promise对象.当定义的时间到了以后,这个promise对象就会 ...
- angular.js 中同步视图和模型数据双向绑定,$watch $digest $apply 机制
Angular.js 中的特性,双向绑定. 让视图的改变直接反应到数据中,数据的改变又实时的通知到视图,如何做到的? 这要归功于 scope 下面3个重要的方法: $watch $digest $ap ...
- 史上最全的Angular.js 的学习资源
Angular.js 的一些学习资源 基础 官方: http://docs.angularjs.org angularjs官方网站已被墙,可看 http://www.ngnice.com/: 官方zi ...
随机推荐
- response.setHeader("Content-disposition","attachment;filename="+fileName) 下载时文件名中存在空格错误
最近在进行文件下载时发现一个问题,就是下面语句运行时,下载某些文件正常,下载某些文件异常,后来发现文件名中有空格的文件火狐浏览器是默认将文件名截断了的 response.setHeader(" ...
- 什么是node.js
1.0什么是nodejs 1.1定义: Node.js是Javascript除了浏览器之外可以运行的另一个环境(runtime).可以为我们提供开启服务功能和提供文件读写功能 1.2特点: 1)基于g ...
- E/MediaPlayer: Should have subtitle controller already set
原文链接:http://stackoverflow.com/questions/20087804/should-have-subtitle-controller-already-set-mediapl ...
- macOS平台下虚拟摄像头的研发总结
一.背景介绍 虚拟摄像头,顾名思义,就是利用软件技术虚拟出一个摄像头硬件设备供用户使用.当我们需要对视频图像进行处理再输出时,虚拟摄像头就具备非常大的价值了.关于如何在Windwos上实现一个虚拟设备 ...
- How To Use ggplot in ggplot2?
1.What is ggplot2 ggplot2基本要素 数据(Data)和映射(Mapping) 几何对象(Geometric) 标尺(Scale) 统计变换(Statistics) 坐标系统(C ...
- 解决移动端click点击问题
下载地址:https://github.com/ftlabs/fastclick 1,为什么移动端点击会有300ms的延迟呢? 从点击屏幕上的元素到触发元素的 click 事件,移动浏览器会有大约 3 ...
- 使用 Http 的 Get 方式读取网络数据
作为移动平台的应用,一定避免不了与网络交换数据,不论是读取网页数据,还是调用API接口,都必须掌握Http通信技术 代码如下: package zw1; import java.io.Buffered ...
- Sql日期时间格式转换大全
简介:我们经常会用到sql日期转换,这里列出了日期输出为字符串的所有代码 输出格式 2014-06-12 ), ) 输出格式 2014-06-12 22:31:18 ), ) 以下是各种转换日期代码号 ...
- Java设计模式:工厂模式
问题提出 Java的工厂模式与现实生活中的工厂的模型是很相似的.工厂是用来做什么?当然是用来生成产品.因此在Java的工厂模式的关键点就是如何描述好产品和工厂这2个角色之间的关系. 下面来仔细描述一下 ...
- 读书笔记 effective c++ Item 50 了解何时替换new和delete 是有意义的
1. 自定义new和delete的三个常见原因 我们先回顾一下基本原理.为什么人们一开始就想去替换编译器提供的operator new和operator delete版本?有三个最常见的原因: 为了检 ...