Ionic-item在导航栏中进行双向数据绑定
Ionic - item does two way data binding in the nav bar
我在导航栏中有一个图标,应该根据位置真/假切换显示还是不显示。在视图中进行测试效果很好,但结果在导航栏中不起作用。两个页面使用相同的控制器。翻译英语
index.html-导航栏
<ion-nav-bar class="bar-stable" ng-controller="DashCtrl">
<ion-nav-buttons side="right">
<i class="icon ion-eye ng-show="vaovivo.valor"></i>
</ion-nav-buttons>
<ion-nav-bar
Account.html-切换
<ion-toggle ng-model="vaovivo.valor" ng-checked="vaovivo.valor">
Modo ao Vivo
</ion-toggle>
Controllers.js
角度模块("启动控制器",[])
.controller('DashCtrl', function($scope,$rootScope) {
$scope.vaovivo = {'valor':false}
})
app.js
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
// setup an abstract state for the tabs directive
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
// Each tab has its own nav history stack:
.state('tab.dash', {
url: '/dash',
views: {
'tab-dash': {
templateUrl: 'templates/tab-dash.html',
controller: 'DashCtrl'
}
}
})
.state('tab.account', {
url: '/account',
views: {
'tab-account': {
templateUrl: 'templates/tab-account.html',
controller: 'DashCtrl'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/dash');
});
更新:index.html-导航栏
<ion-nav-bar class="bar-stable" ng-controller="DashCtrl">
<ion-nav-buttons side="right">
<i class="icon ion-eye" ng-show="vaovivo.valor"></i>
</ion-nav-buttons>
<ion-nav-bar>
逻辑看起来不错,但有一件事可能会阻止ng show在导航栏中工作。您没有正确关闭离子导航栏,这可能是问题所在。
首先,通过添加结束引号来适当地结束ng类
<i class="icon ion-eye" ng-show="vaovivo.valor"></i>
第二,适当关闭离子导航栏。
</ion-nav-bar>
相关文章:
- 在VanillaJS中模拟模型双向数据绑定
- Telerik rad组合框多列数据绑定
- 数据绑定:'系统Char'不包含名为'xxxxx'
- OnsenUI AngularJS数据绑定无法正常工作
- Ionic-item在导航栏中进行双向数据绑定
- 基本D3.js:如何将具有其他属性的数据绑定到元素
- 使用自定义数据属性或将数据绑定到处理程序来处理事件
- ListView的ItemTemplate内的自定义HtmlControl的数据绑定失败
- $http中的Angular 1数据绑定承诺不起作用
- 在何处和何时添加具有数据绑定的元素
- 使用AngularJs数据绑定的三元运算符显示图像
- 为什么针对工厂的Angular数据绑定只适用于函数
- 敲除:如何使用可见数据绑定可见来隐藏段落标记
- 在数据绑定中使用对象敲除绑定
- 如何在angularjs中检查Kendo树视图数据绑定事件
- 将json数据绑定到剑道网格
- AngularJS数据绑定中断ngRepeat+奇怪行为
- JavaScript HTMLElement 属性上的数据绑定 在 Polymer 中
- 视窗 8/Metro UI 数据绑定 JavaScript
- Windows商店js应用程序导航控件导致数据绑定问题