var elements = tElement[0].getElementsByTagName('mw-template');
console.log(elements);
console.log(elements instanceof HTMLCollection);
console.log(elements.item(0));
console.log(elements[0]);
[item: function, namedItem: function]
0: mw-template.ng-scope
1: mw-template.ng-scope
2: mw-template.ng-scope
3: mw-template.ng-scope
4: mw-template.ng-scopelength:
5__proto__: HTMLCollection
directives.js:137 true
directives.js:138 null
directives.js:139 undefined console.log(tElement[0].children[0].children);
console.log(tElement[0].children[0].children[0]);
[item: function, namedItem: function]
0: mw-block-toolbar.ng-scope
1: mw-template.ng-scope
2: mw-template.ng-scope
3: mw-template.ng-scope
4: mw-template.ng-scope
5: mw-template.ng-scopelength:
6__proto__: HTMLCollection
undefined
.directive('mwDelegateBlockList',['$compile','mwParse',function($compile,mwParse){ return { restrict:'E',// template:template,// transclude:true, compile:compile } // function template(element, attributes) { // } function compile(tElement,tAttrs) { var html = tElement.html(); tElement.html(''); var format = tAttrs['mwFormat'] || 'list'; if (format == 'grid') { html = `<md-grid-list>${html}</md-grid-list>`; } else if (format == 'table') { html = `<table>${html}</table>`; } else { // 'list' html = `<md-list>${html}</md-list>`; } var $content = angular.element(html); function link(scope, element, attributes, constructor) { console.log('scope',scope); var children = $content.children(); // selector children('mw-template') does not work var length = children.length; for (var i = 0; i < length; i++) { var child = angular.element(children[i]); if (child.prop('tagName').toLowerCase() == 'mw-template') { var mwIf = child.attr('mw-if'); if (mwIf) { // check if template is required for current format var retain = mwParse.expression(mwIf)(scope); // if not remove it if (!retain) child.remove(); } } } console.log('$content',$content); var content = $compile($content)(scope); element.append(content); } return link; }}])