Router state views based on platform


#1

I am trying to show different views based on platform, we can say “dinamic views parameter”, something like this:

.state('tabsController.topics', {
  url: '/topics',
  views: function(){
    if(ionic.Platform.isAndroid()) {
      return {
          'menuContent': {
            templateUrl: 'templates/topics.html',
            controller: 'topicsCtrl'
          }
      }
    } else {
      return {
        'tab1': {
          templateUrl: 'templates/topics.html',
          controller: 'topicsCtrl'
        }
      }
    }

  }
})

Anyone knows whats wrong with this code. Seams return value is not good. Need it to show tabs on ios and sidemenu on android.


#2

Works great when used like this:

.state(‘tabsController.topics’, {
url: ‘/topics’,
views: {
‘menuContent’: {
templateUrl: ‘templates/topics.html’,
controller: ‘topicsCtrl’
}
}
})