angular-ui/ui-router を使用しており、状態変化時にレンダリングされるように定義された分離スコープを持つディレクティブ/コンポーネントがあります。
$stateProvider
.state('about', {
url: '/about',
template: '<about></about>'
})
.state('blog', {
url: '/blog',
template: '<blog></blog>'
})
私のメインページは、コントローラーにすべての権限を持つユーザーをロードするディレクティブです
app.directive('main', function() {
return {
...
template: "<div><header></header><div ui-view></div></div>",
controller: [..., function(...) {
$scope.user = // $http load user
}]
);
さまざまな状態に移動するときに、ユーザーがすべての ui-view ディレクティブ/コンポーネントに渡されるようにします。ただし、状態が変化するたびにユーザーをresolve
ロードしたり、$rootScope
次のようなものを探しています。ユーザーは親スコープのものです。
$stateProvider
.state('about', {
url: '/about',
template: '<about user="user"></about>'
})
.state('blog', {
url: '/blog',
template: '<blog user="user"></blog>'
})
これを行う方法はありますか?