创建了一个包含日期选择器的指令。用户输入时,我正在创建一个验证码。
如何将datepicker的值从隔离范围更新为控制器范围?
朋克车示例
https://plnkr.co/edit/f8s5KOi62xsEVj6S7ucx?p=preview
app.directive('myDatepicker', function() {
return {
restrict: 'E'
scope: {
ngModel: "=",
},
require: 'ngModel',
link: function(scope, element) {
scope.keyUpValidate = function(val, event){
var newVal = val || event.target.value;
console.log(newVal)
// change value of selected on keyup event
// logic here
// how to update the ngModel?
scope.ngModel = newVal; // doesnt work
}
}
};
});