简体   繁体   English

AngularJS UI-Router“否则”状态未加载

[英]AngularJS UI-Router “otherwise” state not loading

My index.html page has 3 views: 我的index.html页面具有3个视图:

<header ui-view="header"></header>
<main ui-view="content"></main>
<footer ui-view="footer"></footer>

I just changed the site to use these 3 views instead of the initial single view. 我只是将站点更改为使用这3个视图,而不是最初的单个视图。

All the routes in my app work fine, for example the "home" view: 我的应用程序中的所有路由都可以正常工作,例如“ home”视图:

  $stateProvider.state('home', {
  url: '/home',
  data: {
    pageTitle: 'Home',
    access: 'private',
    bodyClass: 'home'
  },

  views: {
    'header': {
      templateUrl: 'modules/header/header.html'
    },
    'content': {
      controller: 'HomeController as home',
      templateUrl: 'modules/home/templates/home.html'
    },
    'footer': {
      templateUrl: 'modules/footer/footer.html'
    }
  }
});

My issue is the "otherwise" state in the app does not correctly load the "home" state as it should. 我的问题是应用程序中的“其他”状态无法正确加载“原位”状态。 The page is blank, no console errors. 该页面为空白,没有控制台错误。 Here's the state in my app.module: 这是我的app.module中的状态:

angular.module('app').config(function ($stateProvider) {

$stateProvider.state('otherwise', {
  url: '*path',
  template: '',
  data: {
    pageTitle: '',
    access: 'public',
    bodyClass: ''
  },
  controller: function ($state) {
    $state.go('home');
  }
 });
});

What am I missing here? 我在这里想念什么?

I am not sure if your wild char works or not. 我不确定您的野生字符是否有效。

Ideally I use the following for default routing: 理想情况下,我将以下内容用于默认路由:

 $urlRouterProvider.otherwise('/app/home');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM