Home Chained Templates in Angular
Reply: 0

Chained Templates in Angular

user1152
1#
user1152 Published in April 24, 2018, 8:35 am

Just learning Angular2/4 so please bear with me...

Assume I have a CoursesComponent which has a list of CourseComponents. The HTMLTemplate for CoursesComponent simply iterates the CourseComponent (list) field and displays each course.

I want the CourseComponent to handle the display of course with it's own HTMLTemplate.

CourseComponent HTMLTemplate (with selector:'course')

<div class='course'>
{{title}}({{code}})
<br/>
{{description}}
</div>

CoursesComponent HTMLTemplate (with selector:'courses')

<div class='courses'>
<ul>
<li *ngFor='let c of courseList'><course></course></li>
</ul>
</div>

AppComponent HTMLTemplate

<div>
<courses></courses>
</div>

How do you achieve this? Is it even possible? Can templates be chained in this fashion?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.360641 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO