当我调用$ state.go($ state.current,{},{reload:true});在我的控制器中,我的标题消失了
如果我对此进行评论,标题不会消失,但是我的视图更新没有所需的影响
它没有隐藏,它完全从DOM中移除
下面的代码是一个使用cordova插件来调用本机sdk的函数,在sdk完成之后,它返回到javascript层,标题就在那里,当它命中$ state.go($ state.current, {},{reload:true});标题消失
function miSnapCheckFront(){ //get image of front of check
MiSnapPlugin.captureCheck('front', success, error);
function success(data){
depositService.checkObj.frontImage = data.EncodedImage;
depositService.checkObj.frontImageOriginal = data.OriginalImage;
$state.go($state.current, {}, {reload: true});
}
function error(err){
navigator.notification.alert('MiSnap is Cancelled check scan: ' + err, onClose, 'Scan Error', 'Close');
function onClose(){}
}
}
<ion-view hide-back-button="true" can-swipe-back="false" view-title="{{vm.title}}">
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-ios-close-empty" data-ng-click="vm.cancelCheck()"></button>
</ion-nav-buttons>
<ion-content>
<form name="vm.captureCheckForm" novalidate>
<div class="list-borderless">
<div class="card">
<!-- Memo -->
<label class="item item-input" ng-cloak>
<span class="input-label">Memo</span>
<input type="text" name="memo" data-ng-model="vm.memo" placeholder="Check Memo" data-ng-change="vm.checkMemoChange()">
</label>
</div>
<!-- Scan Check Front Button -->
<div class="card" data-ng-click="vm.miSnapCheckFront()">
<div class="item item-text-wrap" data-ng-class="{'lightest-yellow-bg': vm.frontImage === 'error'}">
<div class="item item-icon-right" data-ng-class="{'lightest-yellow-bg': vm.frontImage === 'error'}">
<h2 data-ng-show="vm.frontImage === null || vm.frontImage === 'error'">Capture Check Front</h2>
<img class="capture-check-thumbnail ng-hide" data-ng-show="vm.frontImage !== null" data-ng-src="{{'data:image/jpeg;base64,' + vm.frontImage}}"><!-- {{'data:image/jpeg;base64,' + vm.frontImage}} -->
<i class="icon ion-ios-camera-outline positive ng-hide" data-ng-show="vm.frontImage === null"></i>
<i class="icon fa fa-check-circle-o balanced ng-hide" data-ng-show="vm.frontImage !== null"></i>
</div>
</div>
</div>
<!-- Scan Check Back Button -->
<div class="card" data-ng-click="vm.miSnapCheckBack()">
<div class="item item-text-wrap" data-ng-class="{'lightest-yellow-bg': vm.rearImage === 'error'}">
<div class="item item-icon-right" data-ng-class="{'lightest-yellow-bg': vm.rearImage === 'error'}">
<h2 data-ng-show="vm.rearImage === null || vm.rearImage === 'error'">Capture Check Back</h2>
<img class="capture-check-thumbnail ng-hide" data-ng-show="vm.rearImage !== 'error' && vm.rearImage !== null" data-ng-src="{{'data:image/jpeg;base64,' + vm.rearImage}}"><!-- data:image/jpeg;base64, -->
<i class="icon ion-ios-camera-outline positive" data-ng-hide="vm.rearImage !== null"></i>
<i class="icon fa fa-check-circle-o balanced ng-hide" data-ng-show="vm.rearImage !== 'error' && vm.rearImage !== null"></i>
<i class="icon ion-ios-reverse-camera-outline energized ng-hide" data-ng-show="vm.rearImage === 'error' && vm.rearImage !== null"><span class="rescan-text">Rescan</span></i>
</div>
</div>
</div>
</div>
</form>
</ion-content>
<!-- Footer -->
<div class="bar bar-footer royal-bg stable" >
<a class="title" data-ng-click="vm.submitCheck(vm.captureCheckForm.$error)">
<span ng-if="vm.type === 'SINGLE'">Submit Check</span>
<span ng-if="vm.type === 'MULTIPLE'">Add Check</span>
</a>
</div>
答案 0 :(得分:1)
您可以在angular.run()
中添加以下代码$rootScope.$on('$ionicView.enter', function(e) {
$ionicNavBarDelegate.showBar(true);
});
答案 1 :(得分:1)
我用下一个代码解决了这个问题:
$state.go($state.current, {}, {reload: false})
.then(function(){
setTimeout(function() {
$window.location.reload(true);
});
})
答案 2 :(得分:0)
我只是使用$ scope修复了这个问题。$ apply()