Angular: Empty Fiddle

http://angularjs.org/

HTML

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
  Hello, {{name}}!
</div>
<div ng-controller="MyCtrl2">
  Hello, {{name}}!
</div>

JavaScript

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

myApp.service('myService', function() {
  	console.log('instantiating service');
    
    this.someFunc = function() {
        return 'hello from service';
    }
});

myApp.factory('myFactory', function() {
  	return {
    	someFunc : function() {
            console.log('instantiating factory');
        }
});

function MyCtrl($scope, myService, myFactory) {
    console.log('MyCtrl:service', myService.someFunc());
    console.log('MyCtrl:factory', myFactory.someFunc());
    $scope.name = 'Superhero';
}

function MyCtrl2($scope, myService, myFactory) {
    console.log('MyCtrl2:service', myService.someFunc());
    console.log('MyCtrl2:factory', myFactory.someFunc());
    $scope.name = 'World';
}