对于 datepicker 控件,我向输入元素添加了一些自定义属性:
<input id="inputDatepicker" ng-model="currentAppointment.date" data-date-format="dd.mm.yyyy" datepicker changedates="currentAppointment.start">
为此,我创建了一个指令来构建日期选择器:
.directive('datepicker', function ($filter) {
return {
restrict: 'A',
require: '?ngModel',
link: function ($scope, $element, $attributes, $ctrl) {
$scope[$attributes.changedates] ... do not work
$element.datepicker();
}
}
});
我如何访问 changedates-attribute 中提到的范围变量?在我上面的例子中,我想访问$scope.currentAppointment.start