Last active
December 25, 2015 19:59
-
-
Save ada-lovecraft/7031158 to your computer and use it in GitHub Desktop.
Invoking an AbstractController
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 = angular.module('app') | |
AbstractController = ($scope) -> | |
$scope.namespace = 'abstract' unless $scope.namespace | |
# to save you a lot of typing... | |
namespace = $scope[$scope.namespace]; | |
namespace.setup = (value) -> | |
namespace.setupComplete = true | |
namespace.x = value | |
AbstractController.$inject = ['$scope'] | |
app.controller 'FooController', ($scope, $injector, $log) -> | |
$scope.namespace = 'foo'; | |
$injector.invoke AbstractController, this, {$scope: $scope} | |
#to save you a lot of typing... | |
namespace = $scope[$scope.namespace]; | |
namespace.setup('bar') | |
$log.log namespace.x | |
# 'bar' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment