2017-01-22 55 views
0

对不起,我的英语不是很好。离子标签有问题。 下面的代码是我模块包含三个选项卡将参数传递给所有选项卡[IONIC]

angular 
    .module('app.infocomplejo', ['ionic','ngCordova','app.comun']) 
    .config(function($stateProvider, $urlRouterProvider) { 
     $stateProvider 
      .state('tab', { 
       url: '/tab', 
       abstract: true, 
       templateUrl: 'scripts/usuario/info-complejo/tabs.html' 
      })    
      .state('tab.canchas', { 
       url: '/canchas', 
       views: { 
        'tab-canchas': { 
         templateUrl: 'scripts/usuario/info-complejo/canchas/tab-canchas.html', 
         controller: 'CanchasController as cc' 
        } 
       } 
      }) 
      .state('tab.informacion', { 
       url: '/informacion', 
       views: { 
        'tab-informacion': { 
         templateUrl: 'scripts/usuario/info-complejo/informacion/tab-informacion.html', 
         controller: 'InformacionController as ic' 
        } 
       } 
      }) 
      .state('tab.comentarios', { 
       url: '/comentarios', 
       views: { 
        'tab-comentarios': { 
         templateUrl: 'scripts/usuario/info-complejo/comentarios/tab-comentarios.html', 
         controller: 'ComentariosController as cm' 
        } 
       } 
      }); 
      // if none of the above states are matched, use this as the fallback 
      $urlRouterProvider.otherwise('/tab/informacion'); 
      }); 

以下是我如何调用模块

function verInformacionComplejo(complejo) { 
     $state.go('tab.informacion', {complejo: complejo}); 
    } 

我的问题是,如何传递将在所有选项卡中使用的参数?

我希望你能帮助我!谢谢

+0

访问来自InformacionController该对象为什么不使用localStorage – digit

回答

0

使用angularjs服务在选项卡之间共享数据。那是简单的方法。

例如。

  • 实现一个angularjs服务(如为myService)
  • 然后把COMPLEJO对象到该服务
  • 然后你就可以通过注射服务(为myService)到控制器