Another solution if you do not have control over dynamic content
This works if you did not load your element through a directive (that is, as in the example in the jsfiddles comments).
Wrap Your Content
Wrap your content in a div so you can select it if you are using jQuery . You can also use your own javascript to get your element.
<div class="selector"> <grid-filter columnname="LastNameFirstName" gridname="HomeGrid"></grid-filter> </div>
Use Angular Injector
You can use the following code to get a link to compile $ if you don't have one.
$(".selector").each(function () { var content = $(this); angular.element(document).injector().invoke(function($compile) { var scope = angular.element(content).scope(); $compile(content)(scope); }); });
Summary
The original post seemed to suggest that you have a link to compile $. Obviously, this is easy when you have a link, but I am not, it was the answer for me.
One warning from previous code
If you use the asp.net/mvc package with a minimal script, you will have problems deploying in release mode. The problem occurs as an Uncaught: [$ injector: unpr] error, which is caused by a minifier clutter with the Angular javascript code.
Here is a way to fix it :
Replace the previous code snippet with the next overload.
... angular.element(document).injector().invoke( [ "$compile", function($compile) { var scope = angular.element(content).scope(); $compile(content)(scope); } ]); ...
This caused a lot of grief for me before I brought it together.
jwize Jun 05 '14 at 11:15 2014-06-05 11:15
source share