Skip to content

Instantly share code, notes, and snippets.

@wuxiaoying
Created June 23, 2014 20:44
Show Gist options
  • Save wuxiaoying/f118fd6bbfbb89e497d9 to your computer and use it in GitHub Desktop.
Save wuxiaoying/f118fd6bbfbb89e497d9 to your computer and use it in GitHub Desktop.
extendsScope_module = angular.module 'classy-extends', ['classy-core']
###
Note that this does NOT get the mixin class dependencies as of now.
###
extendsScope_module.classy.plugin.controller
name: 'extends'
localInject: ['$controller']
baseClasses: []
options:
enabled: true
ignore: ['constructor', 'init', 'initScope']
isActive: (klass, deps) ->
if @options.enabled and klass.mixins
if !deps.$scope
throw new Error "You need to inject `$scope` to use the watch object"
return false
return true
preInitBefore: (classConstructor, classObj, module) ->
if classObj.isBaseClass
@baseClasses.push classObj.name, classConstructor
if baseClassName = classObj.extends
# No controller here
@$controller baseClassName
return
preInit: (classConstructor, classObj, module) ->
if baseClass = @baseClasses[classObj.extends]
classConstructor extends baseClass
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment