关闭模式窗体后纳克绑定不更新 [英] ng-bind not updating after closing modal form
本文介绍了关闭模式窗体后纳克绑定不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个列表项的视图。用户点击后,关于这个项目,模态形式显示。当用户变化值和关闭模式,项目,不更新不及时。
I have a view with one list item. After user clicked on this item, the modal form show. When user change value and close modal, the item-not not updating.
查看:
<ion-view ng-controller="settingsController">
<ion-content>
<div class="list">
<ion-item class="item-icon-left" ng-click="openLanguageModal()">
<i class="icon ion-chatboxes"></i>
{{'Language'| translate}}
<span class="item-note">
<div ng-bind="choice"></div>
</span>
</ion-item>
</div>
</ion-content>
<script id="language-modal.html" type="text/ng-template">
<div class="modal">
<ion-header-bar>
<!-- <button class="button button-full button-dark" ng-click="closeLanguageModal()">{{'Done' | translate}}</button> -->
<button class="button button-clear button-positive pull-right" ng-click="closeLanguageModal()">
{{'Done' | translate}}
</button>
</ion-header-bar>
<ion-content>
<ion-list>
<ion-radio ng-model="choice" ng-value="'en'"> English </ion-radio>
<ion-radio ng-model="choice" ng-value="'ru'"> Русский </ion-radio>
</ion-list>
</ion-content>
</div>
</script>
</ion-view>
控制器:
app.controller('settingsController', function($scope, $ionicModal) {
$ionicModal.fromTemplateUrl('language-modal.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.languageModal = modal;
})
$scope.choice = "en";
$scope.openLanguageModal = function() {
$scope.languageModal.show();
}
$scope.closeLanguageModal = function() {
$scope.languageModal.hide();
};
$scope.$on('$destroy', function() {
$scope.languageModal.remove();
});
});
我不明白为什么NG绑定剪掉更新,请帮助
I dont understand why the ng-bind didnt updates, help please
推荐答案
尝试使用:
$scope.model.choice = "en";
在主控制器(让所有其他视图控制器可以inheritate此信息)。
in a main Controller (so that all other view controllers could inheritate this info).
和在所有视图(设置和语言模式)修改为:
and in all view (settings and language-modal) modify to:
ng-model="model.choice"
由于原型继承...
due to prototypal inheritance...
这是一个工作演示: HTTP://$c$cpen.io/beaver71 /笔/ XXaROB
这篇关于关闭模式窗体后纳克绑定不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文