1
コンポーネントルーターを使用するには、Angular UIアプリケーションをAngular UI Router 1.0-beta3に移行します。私は$ rootScopeの状態変更イベントをリッスンしていますが、イベントは発生しません。UIルーター1.0状態変更イベントが機能しない
例:
angular
.module('app', [ 'ui.router' ])
.config(function($stateProvider) {
$stateProvider.state(
'dashboard',
{
url: '/dashboard',
component: 'dashboardComponent',
resolve: {
enabled: function() { throw new Error('NOT ENABLED'); }
}
});
})
.run(function($rootScope) {
$rootScope.$on('$stateChangeError', function() {
// Never called
});
});
は、コンポーネントルーティングでサポートされている状態変更イベントはありますか?
ためdocsを参照してください。 .events – fernando
@fernando良い点。ただし、ui-router v。1.0では状態イベントは推奨されません。 [The docs](https://ui-router.github.io/docs/1.0.0-β3/modules/ng1_state_events.html)では、代わりにトランジションフックに移行することを推奨しています。 – Joseph238
うん、それはまた非常に強力です。現在のプロジェクトでは州のイベントを頻繁に使用しています – fernando