Last active
August 29, 2015 14:04
-
-
Save Igosuki/5cd5e3b253149fcff84a to your computer and use it in GitHub Desktop.
Manage passing data to sub templates without a service
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
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