Skip to content

Instantly share code, notes, and snippets.

@apolzon
Last active December 25, 2015 07:29
Show Gist options
  • Save apolzon/6939522 to your computer and use it in GitHub Desktop.
Save apolzon/6939522 to your computer and use it in GitHub Desktop.
naked and extend example
Cerego.controller "GroupAdminCtrl", ($scope, $routeParams, $filter, GroupUsersResource,
GroupsResource, GroupsService, GoalListSearchResource,
GoalSearchResource) ->
# using underscore.extend to set some defaults on the $scope; this is sorta naked as well in the sense that I believe it gets executed on initialization of the controller
_.extend $scope,
group_id : $routeParams.group_id
group : GroupsService.group
... omitted lots of stuff ...
# this is naked code -- its not in a function, so it gets executed every time this controller is instantiated. its like an unwrapped initialize method
if !GroupsService.group
GroupsService.group_id = $scope.group_id
$scope.group = GroupsResource.get group_id: $scope.group_id
$scope.$watch "group", (group) ->
GroupsService.group = group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment