'use strict';

angular.module('ngAppInit', []).

provider('$init', function(
){
  this.$get = function() {
    return {};
  };
}).

directive('ngAppInit', function(
  $window,
  $init
){
  return {
    compile: function() {
      return {
        pre: function(scope, element, attrs) {
          angular.extend($init, $window.JSON.parse(attrs.ngAppInit));
        }
      };
    }
  };
});

'use strict';

angular.module('data-init', []).

provider('$init', function() {
  this.$get = function(
    $window
  ){
    return $window.JSON.parse(document.querySelector('[ng-app]').dataset.init);
  };
});

Rewrite the logic without using directive
Rewrite the logic without using directive
