有没有人见过这种行为?
我有一个这样定义的按钮
<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.
如您所见-一旦加载设计器控制器,就会触发到根状态的转换-可能导致这种情况?