jQuery 日期选择器在 Angular.js 中很难实现

jQuery datepicker is hard to implement in Angular.js

我是 Angular.js 的初学者。我有一个处于开发阶段的 Web 应用程序,使用 Angular。我想在我的表单中实现一个日期选择器。

请查看下面我的源代码。

app.js

myapp.directive('datepicker', function () {
    return {
        restrict: 'A',
        require: 'ngModel',
        link: function (scope, element, attrs, jsCtrl) {
            element.datepicker({
                dateFormat: 'DD, d  MM, yy',
                onSelect: function (date) {
                    jsCtrl.$setViewValue(date);
                    scope.$apply();
                }
            });
        }
    };
});

jsCtrl

var ProfileWebModel = {
    Name: 'Test Customer',
    Email: 'customer@wifi.com',
    Password: '111111',
    ConfirmPassword: '111111',
    DOB: 'DOB',
    Address: 'xxxx',
    City: 'Ernakulam',
    Country: 'India',
    Pincode: '683212',
    Phone: '9998989892'

}
  $scope.setViewValue = function (value) {

    ProfileWebModel.DOB = value;

}

DatePicker 已正确呈现。但是当我在 DatePicker 中 select 一个日期时,网页导航到其他页面。是否需要路由配置?

导航问题来自未捕获的 href 单击事件停止传播。你可以挂钩 jquery 并添加一个 event.stopImediateprogagation 吗? http://api.jquery.com/event.stopimmediatepropagation/