如何使用 Jquery 全局触发角度的模型更改?或者如何使用 Jquery 通知角度模型更改



我正在尝试获取页面的所有日期时间并将其替换为jquery日期时间选择器。

尝试用jquery处理它的原因是:我不想要求所有开发人员更改他们的代码并将其替换为新组件,因此jquery将用自定义DateTime选择器替换日期时间并触发组件的更改事件以更新模型,

我做了什么

在我的页面中找到了使用以下代码的所有日期类型的输入:

 $("input[type=date]").each(function () {
// Add picker to input parrent i will hide the current input , i will fill it in the picker change value 
 $(this).parent().append("<input readonly='readonly'  palceholder='" + dateFormat + "'  class='pickerJquery " + objClass + "' style='" + style + " ; height:31px !important ; z-index: 100000' type='text' />");

 $(".pickerJquery").datepicker({
          onSelect: function (dateText, inst) {
            const date = $(this).datepicker('getDate');            
            // set value here 
            $(field).val(value);
            // Trying to call the model change of angular ****** this part not works
              $(field).trigger("click");
              $(field).trigger("dblclick");
              $(field).trigger('input');
              $(field).trigger('change');
          }
        });

});

问题:使用 jQuery 设置值后模型未更新并触发单击/数据库单击/输入/更改...

知道吗?

与 Dileep 交谈或检查数据表组件,我认为它是一样的。

最新更新