2016-05-14 28 views
1

根據位置true/false切換,我在導航欄中有一個圖標應顯示或不顯示。在視圖中測試完美,但結果不起作用的導航欄。這兩個頁面使用相同的控制器。翻譯英語Ionic - item在導航欄中雙向進行數據綁定

index.html的 - NAV酒吧

<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

angular.module(」 starter.controllers',[])

.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'); 

}); 

UPDATE: index.html的 - NAV酒吧

<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> 
+0

你能告訴我路線文件嗎? – sumair

回答

0

邏輯看起來聲音,但有一兩件事,可能會阻止ng-show在導航欄中工作。您沒有正確關閉ion-nav-bar,可能是問題所在。

首先,納克級的密妥像通過添加閉引號

<i class="icon ion-eye" ng-show="vaovivo.valor"></i> 

其次正確關閉離子NAV-巴。

</ion-nav-bar> 
+0

抱歉,基本的錯誤是轉錄代碼。問題仍在繼續。 – alebarros