Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange
commit
01246f65ba
@ -0,0 +1,25 @@
|
||||
app.directive('inputOnChange', function(){
|
||||
return{
|
||||
restrict: 'A',
|
||||
scope: {},
|
||||
link: function (scope, element, attrs) {
|
||||
var onChangeFunc = scope.$eval(attrs.inputOnChange);
|
||||
element.bind('change', onChangeFunc);
|
||||
|
||||
scope.uploadDown = function () {
|
||||
var file = event.target.files[0];
|
||||
//判断类型是不是图片
|
||||
if (!/image\/\w+/.test(file.type)) {
|
||||
alert("非图片");
|
||||
return;
|
||||
}
|
||||
var reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = function (e) {
|
||||
alert(this.result);//base64
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in new issue