Skip to content

Instantly share code, notes, and snippets.

@adamkleingit
Created November 26, 2014 09:12
Show Gist options
  • Save adamkleingit/0a08c18d77cf5e8e0e01 to your computer and use it in GitHub Desktop.
Save adamkleingit/0a08c18d77cf5e8e0e01 to your computer and use it in GitHub Desktop.
Closures for Angular controllers
var MyCtrl = (function () {
var myDependency;
function MyCtrl(_myDependency_){
myDependency = _myDependency_;
}
MyCtrl.prototype.myFunction = function () {
return myDependency.aFunction();
}
return MyCtrl;
})()
angular.module('myApp').controller('myCtrl', MyCtrl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment