How to ensure factory promise resolves before directive executes
<p>So far studying existing stackoverflow answers always helped me along, and I could always find an answer, but now I'm really stuck.</p>

<p>I'm building an app, which uses a directive to create calender month type boxes.</p>

<pre><code>&lt;app2directive class="column_50" jahr="2016" mon="November"&gt;&lt;/app2directive&gt;
</code></pre>

<p>the directive code therefore isolates the scope and utilizes a templateUrl file to draw the calendar month</p>

<pre><code>App.directive('app2directive',function( YEARS, MONTHS, DAYS){

return {
    restrict:"ACE",
    scope:{},
    replace:true,
    templateUrl:"templates/cal_directive3.html",
    controller: function ( $scope, $attrs, $injector, $log, YEARS, MONTHS, DAYS) {            var factoryName = "datumFactory" ;
        var factoryTonnen = "jsonsrc" ;
        var factoryInstance = $injector.get( factoryName ) ;
        var tonnenInstance = $injector.get( factoryTonnen ) ;

        var wtf = $scope.jsondata.get().then( function( promise){
            console.log( "jsondata", promise ) ;
            //$scope.tonnen = promise ;
        }, function( error){
            console.log( "error", error ) ;
        }) ;


});
</code></pre>

<p>At the moment i use an $injector to inject a factory which runs a $http-request to read a json-file with data such as holidays or other static information specific to the chosen year and month(s). </p>

<pre><code>App.factory( 'jsonsrc', function( $http, $q ){ 
return {
    get: function(){
        var deferred = $q.defer() ;
        $http.get( 'termine_2016.json' )
            .success(function(data, status, headers, config) {
                deferred.resolve( data ) ;
            }).error(function(data, status, headers, config) {
                console.log( "[jsonsrc] request didnot work!" );
                deferred.reject( data ) ;
            }) ;
        return deferred.promise ;
    }
}
</code></pre>

<p>});</p>

<p>The effect of it is, that the same call to $http is run 12 times for a full year page load. </p>

<p>My concern is to refactor the file, so that I could preferably load the json data into the main-controller and the directive scope could inherit from the parent scope. </p>

<p>By its nature the call returns a promise. The directive would need means to wait for that promise to resolve before it should proceed, but right now I'm stuck on how to go about it. Thanks in advance for any pointers!</p>