angularjs - How to get a directive's original content when using a template? -
Looking at an instruction with a template, How could the original material get? For example: HTML: & lt; Div & gt; Template & lt; / Div & gt; ', Compiled: function (element) {console.log (element.html ()); // output & lt; Div & gt; Template & lt; / Div & gt; // I & lt; How to get input type = "text" & gt ;?}};}); Since you are now It is necessary for display purpose and do not really use it with binding and other materials and it is touched by angular before you need it. You can use the property expression syntax of the Example: - Extended examples to support multiple: - Any Jquery solutions (work for
& lt; div my-directive & gt; & Lt; Input type = "text" & gt; & Lt; / Div & gt; Directive ('my directive', function () {return {template: '' app '', []): {
template directive.
var content; Template: Function (Lm) {content = elm.html (); // html returns' & lt; Div & gt; Template & lt; / Div> Save; },
. Directive ('myDirective', function ($ timeout) {var content = {}; var loadedDiars; return {scope: true, templates: function (elm) {loaded darts = loaded dirers · angular element (document.quire selectorsall ('[Directive]'); // LoadedDirs
index )
. Directive ('my directive', function ($ timeout)) {var content = {}, idx = 0; Return {scope: true, template: function (elm) {elm.idx = idx; // a moving index / element to its related index content [idx ++] = alm html // To save a element on the map returns HTML '& lt; Div & gt; Template & lt; Div & gt; & Lt; Pre & gt; {{orig}} & lt; / Pre & gt; ; & Lt; / Div & gt; & Lt; / Div & gt; '}, Link: function (area, element) {var idx = element.idx; // element scope.orig = content [idx]; // get idx property value delete content to remove content [idx]; // Remove the key if (! Object. Key (content)) {idx = 0;} // once all are loaded}}}};
Comments
Post a Comment