具体如何实现呢?请看下面代码哈哈哈。
在angular项目中,如果要给<input type="file">标签添加 onchange 事件,已:onchange="angular.element(this).scope().setImagePreviews()" 方式添加。
html:<body ng-controller="main"> <div class=upload-file-content> <div class="row"> <div class="col-md-3"> <label>资质证照</label> </div> <div class="col-md-9"> <div class="show-img" ng-show="imgArrs.length>0"> <img ng-repeat="imgEle in imgArrs" ng-src="{{imgEle.src}}" class="yz inbuy"> </div> </div> </div> <div class="row" ng-show="customerData.errorMsg.logo"> <div class="col-md-3"></div> <div class="col-md-9 error-msg" ng-bind="customerData.errorMsg.logo"></div> </div> <div class="row"> <div class="col-md-3"></div> <div class="col-md-9"> <input class="upload-file-img" type="file" name="file" id="personsFile" multiple="multiple" accept="image/*" onchange="angular.element(this).scope().setImagePreviews()"> </div> </div> </div> </body>