【发布时间】:2016-11-11 22:35:38
【问题描述】:
<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 来说似乎是意料之外的......
【问题讨论】:
标签: javascript angularjs ng-show angular-ng-if ng-hide