Last active
August 29, 2015 14:06
-
-
Save connor4312/ec15140e972dc27ae465 to your computer and use it in GitHub Desktop.
Find an angular element by in a scope.
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
/** | |
* Simple jquery extension to find all elements in a certain Angular scope. | |
* Usage: | |
* | |
* var myElement = $.inScope('.item', $scope); | |
* | |
* @param {string} selector | |
* @param {Angular.Scope} $scope | |
* @returns {jQuery} | |
*/ | |
jQuery.inScope = function (selector, $scope) { | |
var out = []; | |
jQuery(selector).each(function () { | |
var $el = jQuery(this); | |
if ($el.scope() === $scope) { | |
out.push($el); | |
} | |
}); | |
return jQuery(out); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment