1
votes

I have the next template:

<body>
    <div id="page_wrapper">
        <div id="head_content"
             data-ng-controller="HeaderCtrl"
             data-ng-include="'header/header.tpl.html'">
        </div>

        <div id="main_content" data-ui-view="main"></div>
    </div>
</body>

From the server Angulat gets config by AJAX request. The "main" View is managed by controllers which depend on ui-router by nested states and resolve property of $routeProvider.

But " data-ng-controller="HeaderCtrl" " is used to display a common header for all states and it uses the same config from the server.

At this moment there are 2 request to the server for this config: 1. one for ui-router states for almost all controllers. 2. and a separate for HeaderCtrl

Is there something similar to resolve: {} property for such standalone controllers in AngularJS?

1

1 Answers

0
votes

Basically, since the HeaderCtrl nested into some MainController, his scope protptypically inherit scope of the MainController and you can access $scope.configuration property of parent from any children controllers. And also, you can explicitely notify all chidlren about state change propagating event downward with $scope.$emit and pass your config object as parameter.