Last active
May 28, 2016 14:04
-
-
Save acdesouza/b5d2532a73db41adeaf766afc17d1e93 to your computer and use it in GitHub Desktop.
Define Angular.JS controller as a header file
This file contains 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
# app/application.js | |
# require_tree app/controllers | |
angular.module('myApp').controller('fooCtrl', ctrlImpl); | |
function ctrlImpl () { | |
"use strict"; | |
var ctrl = myApp.ctrlHeader; | |
init(); | |
return ctrl; | |
function init() { | |
ctrl.foo = "hello"; | |
ctrl.asfd = [1,2,3]; | |
someService.get().then(function(response) { | |
ctrl.yada = response; | |
}); | |
} | |
function bar() { | |
return "world"; | |
} | |
function kung() { | |
return "kung"; | |
} | |
function fu() { | |
return "fu"; | |
} | |
} |
This file contains 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
# app/controllers/ctrl.js | |
var myApp.ctrlHeader = { | |
foo: null, | |
asdf: [], | |
yada: {}, | |
bar: bar, | |
kung: kung, | |
fu: fu | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment