一旦控制器加载,ui-router就会转换到根状态

时间:2015-05-30 14:48:48

标签: angular-ui-router angular-ui-router-extras

以前有人见过这种行为吗?

我有一个像这样定义的按钮

<button ui-sref="designer({model: 'foobar' })">

我的状态定义为

{
  name: 'designer',
  state: {
    url: 'designer/:model/:form',
    templateUrl: '/partials/designer.html',
    controller: 'DesignerController',
    controllerAs: 'designer'
  }
}

和像这样的控制器

(function() {
    angular.module('myApp')
        .controller('DesignerController', DesignerController)

    function DesignerController() {
        console.log("-->loaded designer");
    }
})();

当我点击按钮时,我在控制台中得到了这个(我添加了一些调试)

$stateChangeSuccess to designer- fired once the state transition is complete.

-->loaded designer

$viewContentLoaded - fired after dom rendered Object {name: "$viewContentLoaded", targetScope: ChildScope, defaultPrevented: false, currentScope: Object}

$stateChangeStart to undefined- fired when the transition begins. toState,toParams : 
 Object {url: "/", templateUrl: "/partials/main.html", name: "root", status: "exited", onExit: undefined} Object {}

$stateChangeSuccess to root- fired once the state transition is complete.

正如您所看到的 - 一旦加载设计器控制器,就会触发到根状态的转换 - 这会导致什么原因?

0 个答案:

没有答案