我使用angularjs:1.6.5和UI路由器:1.0.3狀態更改不點火,但是ui.router工作,否則
主HTML:
<div ng-app="MusicApp" ng-controller="AppCtrl">
<div ng-include="plugins_url + 'templates/sideMenu.html'"></div>
<md-content ng-controller="playlistController">
<div ng-include="plugins_url + 'templates/header.html'"></div>
<div class="all_content" >
<div ng-show="!isHome">
<div ui-view id="other_views" ></div>
</div>
<div ng-include="plugins_url + 'templates/main.html'" ng-show="isHome"></div>
</div>
</md-content>
[etc]
Content from sideMenu.html:
<li><a ui-sref="charter">Home</a></li>
<li><a ui-sref="charter.test">Test</a></li>
我的問題是,基本上沒有stateChange的提供工作,我已經試過:$ stateChangeError,$ stateChangeCancel,$ stateChangeStart,$ stateChangeSuccess,就像這樣:
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState) {
console.log('called')
})
,但它從來沒有叫......試過把它放在.config中,在每個控制器中,使用$ scope和/或$ rootScope嘗試它,但是nada。
奇怪的是,我認爲這是在我的控制檯的警告:
angular.min.js?1507208413&ver=4.8.2:123 $route service is not available. Make sure you have included ng-route in your application dependencies.
所以它並不會自動ui.router承認,這當然是加載一個文件,並插入到依賴如'ui.router'。最奇怪的部分是,你可以在sideMenu.html中看到ui-sref工作正常......
是否有可能存在兼容性問題...某處?
感謝任何幫助!
編輯: 我試圖與ui.router 0.4.3及以上版本,但它甚至不會啓動應用程序...