Last active
September 8, 2016 04:36
-
-
Save Lokua/c011278ecfcf5ce0ae7a1991f4c990dd to your computer and use it in GitHub Desktop.
angular 1 pass promise to directive w/out isolate scope
This file contains hidden or 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
<div ng-app="app" ng-controller="Controller as vm" directive="directive" promise="vm.promise"></div> |
This file contains hidden or 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 | |
.module('app', []) | |
.controller('Controller', ['$q', Controller]) | |
.directive('directive', directive) | |
function Controller($q) { | |
this.promise = () => $q.when().then(() => console.log('!')) | |
} | |
function directive() { | |
return (scope, _, attrs) => { | |
const promise = scope.$eval(attrs.promise) | |
promise().then(() => console.log('?')) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment