Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AngularJS Mixins - By passing a scope to a mixin you can keep your controllers simple and reuse mixin code through out your app.
window.AppCtrl = ($scope, $route, $timeout) ->
# mixins
mixin_generic($scope) # setup $scope.generic()
# now we can...
# 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