2016-12-17 71 views
0

我在模态中使用的是AngularJS中的file input of jasny-boostrap,所以我也使用了jasny-bootstrap-angular。我有两个疑问:将数据传递给Angular-Jasny-Bootstrap

  1. 当我点击按钮打开模型,我能够选择然后我想要的文件。如果我选择一个文件关闭模型,那么当我再次打开模型时,该文件将处于数据预览中,而不是清理。我想在我的angularjs中传递null值(或重置)这个图像预览(fileinput-preview thumbnail),当我点击我的按钮打开模式时;

  2. 如果一个按钮调用一个模式的点击,我想自动从我的Web服务到数据previw和自动改变获取图像的按钮“删除”和“变化”和我得到的图片服务。

我的HTML:

<div class="fileinput fileinput-new" data-provides="fileinput"> 
<div class="fileinput-preview thumbnail" style="width: 200px; height: 150px;"></div> 
<div> 
<span class="btn btn-primary btn-file"> 
<span class="fileinput-new">Select a image</span> 
<span class="fileinput-exists">Change</span> 
<input type="file" name="file" file-model="fileinput"> <!--compose.myFile--> 
</span> 
<a href="#" class="btn btn-primary fileinput-exists" data-dismiss="fileinput">Remover</a> 
<button class="btn btn-info" ng-click="showInput()">Show Input</button> 
</div> 
</div> 

如果我点击 '显示输入' 我可以看到图像二值,我用这个angularjs:

$scope.showInput = function() { 
    console.log($scope.fileinput.result); 
} 

我使用这个HTML用我的angularjs代码来查看来自web服务的图像,它是一切工作完美的:

<!-- Foto view--> 
<div class="form-group"> 
<img ng-show="equipamento.FotoEquipamento != null" style="height:auto; width:225px;" data-ng-src="{{getImage(equipamento.FotoEquipamento)}}" /> 
</div> 

回答