File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 27
27
* $rootScope.$digest();
28
28
* });
29
29
* </pre>
30
+ *
31
+ * Sometimes you want to get access to the injector of a currently running Angular app
32
+ * from outside Angular. Perhaps, you want to inject and compile some markup after the
33
+ * application has been bootstrapped. You can do this using extra `injector()` added
34
+ * to JQuery/jqLite elements. See {@link angular.element}.
35
+ *
36
+ * *This is fairly rare but could be the case if a third party library is injecting the
37
+ * markup.*
38
+ *
39
+ * In the following example a new block of HTML containing a `ng-controller`
40
+ * directive is added to the end of the document body by JQuery. We then compile and link
41
+ * it into the current AngularJS scope.
42
+ *
43
+ * <pre>
44
+ * var $div = $('<div ng-controller="MyCtrl">{{content.label}}</div>');
45
+ * $(document.body).append($div);
46
+ *
47
+ * angular.element(document).injector().invoke(function($compile) {
48
+ * var scope = angular.element($div).scope();
49
+ * $compile($div)(scope);
50
+ * });
51
+ * </pre>
30
52
*/
31
53
32
54
You can’t perform that action at this time.
0 commit comments