Last active
August 29, 2015 14:02
-
-
Save 8bitDesigner/09c025a0a260f53dbfa0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Controller | |
| constructor: ($injector) -> | |
| @init.apply(@, @injectables.map((val) -> $injector.get(val))) | |
| $injector.get('$scope').$on, '$destroy' => @deinit() | |
| class MyController extends Controller | |
| injectables: '$scope', '$modal' | |
| init: ($scope, $modal) -> | |
| @modal = $modal.open($scope.new()) | |
| @unwatch = $scope.$watch 'foo', @updateFoo | |
| updateFoo: (newval) -> | |
| @foo = newval * 2 | |
| deinit: -> | |
| @modal.close() | |
| @unwatch() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment