<div ng-show="!showTagging" class="form-group">
<div class="form-group">
<div ng-show="!showPreview"> Add a photo of you enjoying a specific whiskey or an image inspired by one!</div>
<hr></hr>
//when file is uploaded below, it sets $scope.post.picturePreCrop
<label id="upload" required ng-model="post.picturePreCrop" ngf-pattern="image/*" ngf-select="droppedFile()" accept="image/*" ngf-accept="'image/*'" ngf-pattern="'.jpeg,.jpg,.png,.bmp'" ngf-max-size="8MB" ngf-max-files="1" ngf-fix-orientation="true">
<div class="add-link"><i class="fa fa-camera"></i><a class="underlined"> Add or Take a Photo:</a></label></div>
<div></div>
<ng-croppie ng-if="post.picturePreCrop" src="post.picturePreCrop | ngfDataUrl" ng-model='post.pictureUrl' update='onUpdate' boundry="{w: 200, h: 200}" viewport="{w: 200, h: 200}" mousezoom="true" zoom="true" type="square">
</ng-croppie>
<img ng-if="!post.picturePreCrop" class="prof-photo" ng-src="{{post.picture || 'https://placehold.it/200x200'}}">
</div>
//once picture is cropped, it sets $scope.post.pictureUrl
<div class="btn btn-lg btn-block btn-success" ng-disabled="post.picturePreCrop === undefined" ng-click="showTagging = true"> Next </div>
`
//when the next button above is hit, $scope.post.pictureUrl is removed, but post.picturePreCrop still persist.
</div>
我正在使用ng-croppie指令。当我隐藏包含ng-croppie的div时,我的裁剪url会在$ scope中消失。
它来自:
pictureUrl:"data:image/png;base64,iVBORw0KGgoAAAAN...
然后,一旦调用ng-show,就转到:
pictureUrl:"data:,"
如果我取消隐藏div,pictureUrl会按预期返回。
即使隐藏了这个pictureUrl属性,如何使其保持不变?
我知道ng-if从dom中删除了元素,但这似乎是出乎意料的ng-show ..
答案 0 :(得分:0)
您的ng-show
指令放在DIV
控件的父ng-croppie
上。
ng-show
切换HTML控件的显示,这意味着当ng-show
条件表达式不满足时,您的整个div(及其内容)将被隐藏,包括DIV
儿童。您需要将ng-croppie
移出此DIV
或将ng-show
指令放在不包含ng-croppie
控件的其他位置。