Could not resolve '…' from state ''

前端 未结 6 894
名媛妹妹
名媛妹妹 2020-12-07 18:49

This is first time i am trying to use ui-router.

Here is my app.js

angular.module(\'myApp\', [\'ionic\'])

.run(function($ionicPlatform) {
  $ionicPl         


        
6条回答
  •  星月不相逢
    2020-12-07 19:20

    This kind of error usually means that some parts of (JS) code were not loaded. That the state which is inside of ui-sref is missing.

    There is a working example

    I am not an expert in ionic, so this example should show that it would be working, but I used some more tricks (parent for tabs)

    This is a bit adjusted state def:

    .config(function($stateProvider, $urlRouterProvider){
      $urlRouterProvider.otherwise("/index.html");
    
        $stateProvider
    
        .state('app', {
          abstract: true,
          templateUrl: "tpl.menu.html",
        })
    
      $stateProvider.state('index', {
        url: '/',
        templateUrl: "tpl.index.html",
        parent: "app",
      });
    
    
      $stateProvider.state('register', {
        url: "/register",
        templateUrl: "tpl.register.html",
        parent: "app",
      });
    
      $urlRouterProvider.otherwise('/');
    }) 
    

    And here we have the parent view with tabs, and their content:

    
    
      
        
      
    
      
        
      
    
    
    

    Take it more than an example of how to make it running and later use ionic framework the right way...Check that example here

    Here is similar Q & A with an example using the named views (for sure better solution) ionic routing issue, shows blank page

    Improved version with named views in a tab is here: http://plnkr.co/edit/Mj0rUxjLOXhHIelt249K?p=preview

      
        
      
    
      
        
      
    

    targeting named views:

      $stateProvider.state('index', {
        url: '/',
        views: { "index" : { templateUrl: "tpl.index.html" } },
        parent: "app",
      });
    
    
      $stateProvider.state('register', {
        url: "/register",
        views: { "register" : { templateUrl: "tpl.register.html", } },
        parent: "app",
      });
    

提交回复
热议问题