Skip to content

Instantly share code, notes, and snippets.

@DevEarley
Last active March 8, 2018 02:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DevEarley/5b49b965a4a5767c22deebea228616f3 to your computer and use it in GitHub Desktop.
Save DevEarley/5b49b965a4a5767c22deebea228616f3 to your computer and use it in GitHub Desktop.
vm.Something = new Something();
angular.module('SomeApp').factory('SomeFactory',
function ($rootScope) {
var Something = function () {
this.Stuff = [];
this.AlertStuffLength = function () {
alert("This much Stuff: " + this.Stuff.length);
}
this.AddStuff = function (_stuff) {
this.Stuff.push(_stuff);
}
return this;
};
return Something;
});
/*
//implementation in some-controller
vm.Something = new Something();
vm.ClickShowStuff = function(){ vm.Something.AlertStuffLength();};
vm.AddStuff = function(){ vm.Something.AddStuff(vm.StuffName)};
// end some-controller
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment