angularjs - Nested directive, where child directive is based on parent attribute -
is possible "tell" directive use specific directive, based on attributes provided first directive?
an example:
let's have following html
<parent-directive child-type="foo" /> and following directive
.directive('parentdirective', function () { return { restrict: 'e', scope: { childtype: '@' }, templateurl: 'parent.html' }; }); where parent.html is
<!-- html --> <{{childtype}} /> <!-- more html --> and foo directive
.directive('foo', function () { return { restrict: 'e', scope: { }, templateurl: 'foo.html' }; }); the above not possible, since directives handled in 2 phases, , childtype isn't linked until second phase, link phase. there way, can this?
the goal here use directives display custom bootstrap modals, header , footer of modals same, body should inserted using set of different directives.
thanks
seems want achieve kind of transclusion http://teropa.info/blog/2015/06/09/transclusion.html
<parent-directive> <foo></foo> </parent-directive> .directive('parentdirective', function () { return { restrict: 'e', tranclude: true, templateurl: 'parent.html' }; }); parent.html:
<div ng-transclude></div>
Comments
Post a Comment