Skip to content

Instantly share code, notes, and snippets.

{
// private field init
var a = 1;
// Initialization logic is here
if () {
...
}
// Private functions
@vitalybe
vitalybe / gist:b8b3714e0b2f3b099ac1
Created May 8, 2014 08:10
Suggested controller/service structure
{
// private field init
var a = 1;
// public field init
$scope.b = 1; // For controllers
this.c = 1; // For services
// call init function
init();
@vitalybe
vitalybe / gist:db36feb702d686cb53b7
Created May 8, 2014 07:54
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({