html部分未加载到ui-view中 [英] html partial is not loaded into ui-view

查看:164
本文介绍了html部分未加载到ui-view中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将一个样本发布到了plunker:

I have posted a sample on plunker:

http://plnkr.co/edit/aOOlXOUIUQTARb8D7jNR?p=preview

我的浏览器控制台没有错误.

I get no errors in my browser console.

我希望当我通过按按钮下方显示按钮的相应按钮来显示日/周/月视图时,显示视图的html.但这不会发生.

I want that when I switch the day/week/month views by pressing the according button that below the buttons the html for the view is shown. But that happens not.

原因可能是因为无论如何都没有在代码中击中day,week和month控制器.

The reason might because the day , week and month controllers are not hit in the code whyever that is.

所以我的问题是为什么控制器没有被加载或ui-view没有被真正的html部分替换.

So my question is why are the controllers not loaded or the ui-view not replaced with the real html partial.

由于我不知道真正的原因,因此我必须同时询问这两种情况.

As I do not know the real cause I have to ask for both cases.

'use strict';
angular
  .module('dates', ['ui.router'])
  .run(['$rootScope', '$state', '$stateParams',
      function($rootScope, $state, $stateParams) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
      }
    ]
  )
  .config(function($stateProvider, $urlRouterProvider) {

    $urlRouterProvider.otherwise('/dateplanner/day');

    $stateProvider
      .state('dates', {
        url: '/dateplanner',
        abstract: true,
        views: {
          'menu@': {
            templateUrl: 'menu.html'
          },
          'content@': {
            templateUrl: 'dateplanner.html',
            controller: 'DateplannerController'
          }
        }
      })
       .state('dates.day', {
        url: '/day',
        views: {
          'planner@': {
            templateUrl: 'dateplannerday.html',
            controller: 'DateplannerDayController'
          }
        }
      })
        .state('dates.week', {
        url: '/week',
        views: {
          'planner@': {
            templateUrl: 'dateplanner.week.html',
            controller: 'DateplannerWeekController'
          }
        }
      })
        .state('dates.month', {
        url: '/month',
        views: {
          'planner@': {
            templateUrl: 'dateplanner.month.html',
            controller: 'DateplannerMonthController'
          }
        }
      })
  });

MENU.HTML

<ul>
  <li ng-class="{ activeButton: $state.includes('dates') }" ui-sref-active="active">
    <a ui-sref="dates.day">date planner</a> 
  </li>
</ul>

DATEPLANNER.HTML

<div class="btn-group">
  <button ui-sref="dates.day" ui-sref-active="btn-primary" type="button" class="btn btn-default">Day</button>

  <button ui-sref="dates.week" ui-sref-active="btn-primary" type="button" class="btn btn-default">Week</button>

  <button ui-sref="dates.month" ui-sref-active="btn-primary" type="button" class="btn btn-default">Month</button>
</div>
<div style="background:white;" ui-view="planner">
Loading...</div>

推荐答案

正如我们在此处讨论的那样:

As we've discussed it here:

该问题与以下内容有关:

the issue is related to the:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆