Replace ng-include node with template?

前端 未结 7 996
感情败类
感情败类 2020-11-30 23:36

Kinda new to angular. Is it possible to replace the ng-include node with the contents of the included template? For example, with:

7条回答
  •  心在旅途
    2020-12-01 00:07

    This is the correct way of replacing the children

    angular.module('common').directive('includeReplace', function () {
        return {
            require: 'ngInclude',
            restrict: 'A',
            compile: function (tElement, tAttrs) {
                tElement.replaceWith(tElement.children());
                return {
                    post : angular.noop
                };
            }
        };
    });
    

提交回复
热议问题