angular+mui点击事件无法触发脏检查的问题,通过angular指令对原生js的onchange事件的封装解决这个问题
ngModule.directive('fileInput', ['$parse',function($parse) {
return {
restrict: "EA",
template: "<input type='file'/>",
replace: true,
link: function (scope, element, attrs) {
var modelGet = $parse(attrs.fileInput);
var modelSet = modelGet.assign;
var onChange = $parse(attrs.onChange);
var updateModel = function () {
scope.$apply(function () {
modelSet(scope, element[0].files[0]);
onChange(scope);
});
};
element.bind('change', updateModel);
}
};
}])

施比受更为有福
- 发布:2017-06-17 09:51
- 更新:2017-06-17 09:51
- 阅读:3215
angualr+mui对<input type="file" />图片上传的onchange事件的封装
分类:MUI
0 个评论
要回复文章请先登录或注册