0
我正在使用datepicker,但這裏面臨的問題關於模型值沒有綁定到模型當我選擇日期沒有任何事情發生,任何人都可以告訴我,我在做什麼錯誤必須是讚賞。在這裏,我正在發送我的代碼。選擇日期值後,顯示日期選擇器只是問題不能綁定到ng-model =「user.dob」。使用datepicker選擇日期值不綁定到模型Angular js
signUpview.html
<div class="col-md-6">
<label for="datepicker" class="col-lg-5 form-label">Date Of Birth:</label>
<div class="col-lg-7">
<input type="text" class="form-control dateBirth" ng-model="user.dob" id="datepicker" name="datepicker" datepicker placeholder="Date Of Birth" required/>
<div class="error" ng-show="newUser_form.datepicker.$dirty && newUser_form.datepicker.$invalid">
<small class="error errorFields" ng-show="newUser_form.datepicker.$error.required"> Date is required.</small>
</div>
</div>
</div>
datepickerDirective.js
app.directive('datepicker', function() {
var linker = function(scope, element, attrs) {
element.datepicker().on('changeDate', function(){
console.log(scope);
$(".datepicker").hide();
});
}
return {
require: 'ngModel',
restrict: 'A',
link: linker
}
});