angular的绑定针对input等获得焦点输入使用

对于datapicker等ui控件赋值的,不能改变绑定显示,

通过js控制改变的,不能改变绑定显示

类似datepicker的情况,使用指令的方式解决问题

栗子

js:

var directives = angular.module("directives",[]);
directives.directive("datepicker",function(){
return function(scope,element,attrs){
$(element).datepicker({
inline :true,
dateFormat : "yy mm dd",
onSelect : function(dataText){
var mPath = $(this).attr("ng-model");
scope.mPath = dataText;
scope.$apply();
}
})
}
})

 

html :

<div ng-app = 'directives'>
<p ng-bind= 'myDateValue' ng-init="99999999"> </p>
<input type="text" datepicker ng-model="myDateValue" />
</div>

相关文章:

  • 2022-12-23
  • 2021-07-12
  • 2021-11-14
  • 2022-12-23
  • 2021-12-30
  • 2021-11-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2021-10-18
相关资源
相似解决方案