Angular: Empty Fiddle

http://angularjs.org/

by boneskull

HTML

<script src="http://code.angularjs.org/1.1.5/angular.min.js"></script>
<div ng-controller="MyCtrl">
    Hello {{data}}!
</div>

JavaScript

var myApp = angular.module('myApp',[]);

myApp.provider('derp', function() {
    this.data = {};
    this.$get = function() {
        return {data: this.data};
    };
});

myApp.config(function($injector) {
    var injector = angular.injector(['ng']),
        $exh = injector.get('$exceptionHandler'),
        $parse = injector.get('$parse'),
        $http = injector.get('$http'),
        $rsp = $injector.get('$rootScopeProvider'),        
        $dp = $injector.get('derpProvider');
    
    $http.get('/').success(function(data) {
        $dp.data = data;
    });;

    // this needs to happen for the XHR req to be made, but it doesn't work
    // because $rsp comes from a different injector.
    $rsp.$get[3]($injector, $exh, $parse).$apply();
});

function MyCtrl($scope, derp) {
    $scope.data = derp.data;
}