Last active
December 25, 2015 07:29
-
-
Save apolzon/6939522 to your computer and use it in GitHub Desktop.
naked and extend example
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
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