I want to make a ng-content
template for a component. But I cant find a tutorial how to solve this.
I want that the syntax in my views look like this:
<slider>
<img src="url" alt="alt">
<img src="url" alt="alt">
</slider>
My Slider
Component:
import {Component, ViewEncapsulation} from '@angular/core';
@Component({
selector: 'flx-slider',
template: `
<section class="slider">
<div class="slider-inner">
<ul>
<li>
<ng-content select="img"></ng-content>
</li>
</ul>
</div>
</section>
`,
styleUrls: ['./module.flx-slider.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class FlxSliderComponent {
constructor() {
}
}
I think all see the problem. At last it must be so, that it creates for every img
an extra li
around the img
. Anyone can tell me, how I can do this?