Last active
December 12, 2015 04:58
-
-
Save wookets/4718161 to your computer and use it in GitHub Desktop.
AngularJS Mixins - By passing a scope to a mixin you can keep your controllers simple and reuse mixin code through out your app.
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
window.AppCtrl = ($scope, $route, $timeout) -> | |
# mixins | |
mixin_generic($scope) # setup $scope.generic() | |
# now we can... | |
$scope.generic() | |
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
# a safer version of $scope.$apply()... It will tame exceptions if $apply() or $digest() is already called. | |
window.mixin_generic = ($scope) -> | |
$scope.generic = () -> | |
console.log 'inside mixin' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment