JavaScript
- 9 ответов
- 0 вопросов
7
Вклад в тег
angular.module('app').directive('rtNumber', [
function() {
return {
restrict: 'A',
link: function($scope, $el) {
var wrapper = document.createElement('div');
wrapper.className = 'wrap';
var el = $el[0];
el.parentNode.insertBefore(wrapper, el);
wrapper.appendChild(el);
}
};
}
]);
angular
.module('app', [])
.directive('myDirective', function() {
return {
restrict: 'A',
scope: {},
link: function(scope, el) {
var childItems = el[0].querySelectorAll('.item');
childItems = Array.prototype.slice.call(childItems);
childItems.forEach(function(node) {
console.log(node);
});
},
transclude: true,
template: '<div class="directive-div" ng-transclude></div>'
};
});