I'm trying to basically nest components, and I believe it will be easier to explain with the code I have.
Basically I have 2 components, I want to use 1 component in the other in a specific way. Here's how I have them set up:
test.component.ts
:
import { Component } from '@angular/core';
@Component( {
selector: 'test',
templateUrl: 'partials/test.html'
} )
export class TestComponent {
constructor() {}
}
another.component.ts
:
import { Component } from '@angular/core';
import { TestComponent } from './test.component';
interface Circle {
show: boolean,
data: any
}
@Component( {
selector: 'another',
directives: [ TestComponent ],
templateUrl: '/partials/another.html'
} )
export class AnotherComponent {
circles: Circle[] = [];
constructor() {
let testElement = document.createElement( 'test' ),
defaultCircles = [
{ show: true, data: testElement }
];
this.circles = defaultCircles;
}
}
partials/another.html
:
<ul>
<li *ngFor="let circle of circles; let i = index">
{{circle.data}} <!-- this just shows [object HTMLElement] -->
</li>
</ul>
How can I get it to show the contents of the directive? I tried replacing the data: testElement
with data: '<test></test>'
and it still doesn't work, it just shows the text <test></test>
.