Angular: Empty Fiddle

http://angularjs.org/

by Nathaniel Anderson

HTML

<div id="bootstrap">
  <div ng-controller="MyCtrl">
    Hello, {{name}}!
  </div>
 <div ng-controller="MyCtrl2">
    Hello, {{name}}!
  </div>
</div>

JavaScript

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

myApp.service('SomeService', function(){
return { val : 'universal' };
})
myApp.controller('MyCtrl', ['SomeService','$scope', function(SomeService,$scope) {
    $scope.name = SomeService.val;
}]);


mySecondApp.controller('MyCtrl2',  ['SomeService','$scope', function(SomeService,$scope) {
    $scope.name = SomeService.val; //'Superhero2';
}]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

//https://stackoverflow.com/a/15280637/1175496
//angular.element('#bootstrap'),
//http://errors.angularjs.org/1.4.8/ng/areq?p0=MyCtrl&p1=not%20a%20function%2C%20got%20undefined
angular.bootstrap(document.querySelector('#bootstrap'),  ['mySecondApp', 'myApp'])
//angular.bootstrap(document.querySelector('#other'), ['mySecondApp']);