Ionic $ state.go not working on device

I am currently working on an application using Ionic. My problem is that $ state.go only works in the browser, but not on the phone. This seems to be a common problem, but after reading many answers to the same questions, I still cannot figure out how to fix it.

A general fix is ​​to make sure you use relative URLs as described here: Using Angular UI-Router with Phonegap , but I still can't get it working. What am I missing?

Link to the plunker: http://plnkr.co/edit/qFJ1Ld6bhKvKMkSmYQC8?p=preview

App.js structure:

.... $stateProvider .state('parent', { url: "/", templateUrl: "parent.html" }) .state('parent.child', { url: "child", templateUrl: "child.html" }) $urlRouterProvider.otherwise("/") }) .... 
+5
source share
2 answers

For state.go to work, you need to enter a $ state dependency on your controller

 app.controller('ParentCtrl', ['$scope', '$state', function($scope, $state) { $scope.$state = $state }]); app.controller('MenuCtrl', ['$scope', '$state', function($scope, $state){ $scope.goTo = function(){ $state.go('menu.kategorier'); } }]); 

and you must register the state you want to go to $ stateProvider

 $stateProvider .state('menu.kategorier', {...}) 

and to go into this state, you need to go from the parent state, for example, to the "menu". you cannot change the state from parent to "menu.kategorier", but you can go to "parent.child" from "parent"

0
source

I solved this by changing my setting for nested views based on this example: http://codepen.io/mhartington/pen/Bicmo

Here is my pluker, for those who are interested:

Plunker: http://plnkr.co/edit/2m5bljMntpq4P2ccLrPD?p=preview

Structure

app.js:

  $stateProvider .state('eventmenu', { url: "/event", abstract: true, template: "<ion-nav-view name='menuContent'></ion-nav-view>" }) .state('eventmenu.home', { url: "/home", views: { 'menuContent' :{ templateUrl: "home.html" } } }) .state('eventmenu.home.home1', { url: "/home1", views: { 'inception' :{ templateUrl: "home1.html" } } }) 
0
source

All Articles