Skip to content

Instantly share code, notes, and snippets.

@Igosuki
Last active August 29, 2015 14:04
Show Gist options
  • Save Igosuki/5cd5e3b253149fcff84a to your computer and use it in GitHub Desktop.
Save Igosuki/5cd5e3b253149fcff84a to your computer and use it in GitHub Desktop.
Manage passing data to sub templates without a service
angular.element(document).ready ->
@mymodule = angular.module 'mymodule'
@mymodule.config [() ->
angular.extend angular, {
isPromise: (promise) ->
promise && (promise.then || promise.$then || (promise.$promise && promise.$promise.then))
}
]
@mymodule.controller 'SomeSubController', () ->
if (promiseFn = angular.isPromise($scope.polymorphicObj))
promiseFn (data) ->
someFunc(data.polymorphicRelation)
else
someFunc($scope.polymorphicObj.polymorphicRelation)
someFunc = (someJson) ->
console.log someJson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment