AngularJS 日历指令
AngularJS directive for calendar
我正在将现有站点迁移到 AngularJS,但我在使用 Boostraps 的日期选择器时遇到了问题。
HTML:
<div id="calendar" class="pull-right"></div>
JS:
$('#calendar').on('changeDate', function(event) {
window.location.href = '/appointments?date=' + event.format();
});
我试过写这样的指令,但它不起作用。
HTML
<div id="calendar" class="pull-right" datepicker></div>
JS:
.directive('datepicker', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.datepicker({
onChangeDate: function() {
...
}
});
}
};
})
有什么想法吗?
然后将 jquery 包含到您的项目中
.directive('datepicker', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
$(element).datepicker({
onChangeDate: function() {
...
}
});
}
};
})
this post 的一个答案对我有用。
app.directive('datetimez', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.datetimepicker({
...
}).on('changeDate', function(e) {
...
});
}
};
});
我正在将现有站点迁移到 AngularJS,但我在使用 Boostraps 的日期选择器时遇到了问题。
HTML:
<div id="calendar" class="pull-right"></div>
JS:
$('#calendar').on('changeDate', function(event) {
window.location.href = '/appointments?date=' + event.format();
});
我试过写这样的指令,但它不起作用。
HTML
<div id="calendar" class="pull-right" datepicker></div>
JS:
.directive('datepicker', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.datepicker({
onChangeDate: function() {
...
}
});
}
};
})
有什么想法吗?
然后将 jquery 包含到您的项目中
.directive('datepicker', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
$(element).datepicker({
onChangeDate: function() {
...
}
});
}
};
})
this post 的一个答案对我有用。
app.directive('datetimez', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.datetimepicker({
...
}).on('changeDate', function(e) {
...
});
}
};
});