Factory as Closure object?

http://angularjs.org/

by John Harley

HTML

<div ng-controller="MySetCtrl">Set, {{myTable}}!</div>
    <div ng-controller="MyGetCtrl">Hello, {{myTable.headerNames}}!</div>

JavaScript

var myApp = angular.module('myApp', []);
myApp.factory('TableService', function() {
    this.headerNames ='Default';
    this.aTable = function() {
        //headerNames = this.headerNames;
        return "gill";
     }
    return  this.aTable;
});
/*
myApp.factory('TableService', function() {
    this.headerNames ='Default';
    myxTable = function() {
        headerNames = function() {
            return "this.headerNames";
        }
        contents = function() {
            return "this.contents";
        }
    }

    return  myTable;
});
*/

function MySetCtrl($scope, TableService) {
    //UserService.name = 'fred';
    $scope.myTable = TableService;
};

function MyGetCtrl($scope, TableService) {
    $scope.myTable = TableService;
};