0

I have two independent components,defined one within the other in HTML. But my second(inner) component does not populate using the template mentioned in the templateUrl property of the inner component.

//first component
angular.module('app').component('toolCtrl', {
  templateUrl: '/NFRManagementTools/static/js/templates/toolCtrl.html',
  controller: ToolCtrl,
  controllerAs: 'vtc',
});

//second coponent

angular.module('app').component('itemsView', {
  templateURL: '/NFRManagementTools/static/js/templates/itemsView.html',
  controller: ItemsViewCtrl

});
<tool-ctrl>
  <items-view></items-view>
<tool-ctrl>

1
  • You don’t see the html for <items-view>? Like it’s not there? Commented May 7, 2019 at 0:24

1 Answer 1

2

You are probably looking for transclude option, in your parent component controller add the following option

angular.module('app').component('toolCtrl', {
  transclude: true,
  templateUrl: '/NFRManagementTools/static/js/templates/toolCtrl.html',
  controller: ToolCtrl,
  controllerAs: 'vtc',
});

And in the parent component template you should specify where to place innards by placing specific tag <ng-transclude></ng-transclude>

Checkout the official documentation and here is a similar problem if you have more than one specific element under parent component.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.