Skip to content

Instantly share code, notes, and snippets.

@subtubes-io
Created April 23, 2014 17:33
Show Gist options
  • Select an option

  • Save subtubes-io/11225323 to your computer and use it in GitHub Desktop.

Select an option

Save subtubes-io/11225323 to your computer and use it in GitHub Desktop.
AngularJS Model Sample
(function () {
"use strict";
angular.module("exampleApp")
.provider("Person", function () {
this.$get = [function () {
var Person = function (id) {
if(!(this instanceof Person)){
return new Person(id);
}
if (Person.cached[id]) {
return Person.cached[id];
}
Person.cached[id] = this;
};
Person.prototype.name = "Guest";
Person.cached = {};
return Person;
}];
})
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment