无法使用Angular.js显示图像

时间:2016-09-16 01:58:49

标签: angularjs ng-file-upload

我无法使用angular.js使用--yes显示图像。我正在上传多张图片。我的代码如下。

ng-file-upload

我的控制器端代码如下所示。

<div ng-repeat="mul in mulImage">
<div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Image{{$index+1}}:</span>
<div>
 <input type="file" class="filestyle form-control" data-size="lg" name="upload_{{$index}}" id="bannerimage_{{$index}}"  ng-model="mul.image"  ngf-pattern="'image/*'" accept="image/*" ngf-max-size="2MB">
<div style="clear:both;"></div>
</div>
<span class="input-group-btn" ng-show="mulImage.length>0">
<img ngf-thumbnail="mul.image" name="pro" border="0" style="width:32px; height:32px; border:#808080 1px solid;" ng-if="mul.image !=null">
<input type="button" class="btn btn-success" name="plus" id="plus" value="+" ng-click="addNewImageRow(mulImage);" ng-show="$last"> <input type="button" class="btn btn-danger" name="minus" id="minus" value="-"  ng-show="mulImage.length>1" ng-click="deleteNewImageRow(mulImage,$index);" ngf-select="onFileSelect1($index);">
 </span>
 </div>
</div>

此处从 $scope.mulImage=[]; $scope.mulImage.push({'image':null}); $scope.buttonName="Submit"; $scope.addNewImageRow=function(mulImage){ mulImage.push({'image':null}); } $scope.deleteNewImageRow=function(mulImage,index){ mulImage.splice(index,1); } $scope.onFileSelect1 = function(index) { } 中的文件夹中选择后,我无法显示图像。

1 个答案:

答案 0 :(得分:0)

尝试添加$ scope。$ apply();

$scope.addNewImageRow=function(mulImage){
    mulImage.push({'image':null});
    $scope.$apply();
}