Last active
September 30, 2017 11:11
-
-
Save alirezamirian/11226faf3d064b191f12e8a2c2a7a1ad to your computer and use it in GitHub Desktop.
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
class RefController { | |
constructor($element, $scope, $parse, $attrs){ | |
'ngInject'; | |
const tagName = $attrs.refOf || $attrs.$normalize($element[0].tagName.toLowerCase()); | |
let instance = $element.controller(tagName); | |
if (!instance && !$attrs.refOf) { | |
instance = $element; | |
} | |
$parse($attrs.ref).assign($scope, instance); | |
} | |
} | |
function refDirective() { | |
return { | |
restrict: 'A', | |
controller: RefController | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment