Skip to content

Instantly share code, notes, and snippets.

@vitalybe
Created May 8, 2014 07:54
Show Gist options
  • Save vitalybe/db36feb702d686cb53b7 to your computer and use it in GitHub Desktop.
Save vitalybe/db36feb702d686cb53b7 to your computer and use it in GitHub Desktop.
Controller structure
app.controller('DemoController', function ($scope, MyService) {
var _count = 0;
function _privateUtil() { // function decomposition
_count += _count + 1;
}
function _handleClick(data) {
_privateUtil();
$scope.answer = MyService.doSomething({
data: data,
count: _count
});
}
function _init() {
// expose "data" to the view
$scope.data = 10;
// expose _handleClick as a "public" method on the $scope
$scope.handleClick = _handleClick;
}
_init();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment