Last active
March 8, 2018 02:18
-
-
Save DevEarley/5b49b965a4a5767c22deebea228616f3 to your computer and use it in GitHub Desktop.
vm.Something = new Something();
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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