您的位置:首页 > Web前端 > AngularJS

angularjs图片上传

2016-12-01 17:57 363 查看
引入

ng-file-upload-shim(.min).js    //h5不支持的浏览器 

ng-file-upload(.min).js

页面使用:

<img data-ngf-src="examplePicFile1 || defaultPicFile"/>

<button data-ngf-select="selectFile($file,0)" data-ngf-pattern="'.png,.jpg,.gif'" data-ngf-multiple="false">按钮文字</button>

<img data-ngf-src="examplePicFile2 || defaultPicFile"/>

<button data-ngf-select="selectFile($file,1)" data-ngf-pattern="'.png,.jpg,.gif'" data-ngf-multiple="false">按钮文字</button>

js:

$scope.defaultPicFile = "图片url"//提示图片

$scope.examplePicFile1 = "";

$scope.examplePicFile2 = "";

//data-ngf-multiple 控制选择单/多张图片true $file 是 数组

$scope.selectFile = function(file,id){

if(id==0){

$scope.examplePicFile1 = file;

//选择后及上传可执行上传方法

//upload();

}else if(id == 1){

$scope.examplePicFile2 = file;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: