I'm new to angular 2, and I'm using angular-rc-4 version.
When I combine angular 2 with bootstrap icon, the template can't be parsed.
Unexpected closing tag "li"
Thanks for your help
Below is my code:
import { Component } from '@angular/core';
import { CourseService } from './course.service';
import { AutoGrowDirective } from './auto-grow.directive';
@Component({
selector: 'courses',
template: `
<h2>Courses</h2>
{{ title }}
<input autoGrow [(ngModel)]="title"/>
<input type="button" (click)="title = ''" value="Clear">
Preview
{{ title }}
<ul>
<li *ngFor="let course of courses">
<i class="glyphicon glyphicon-star" />
</li>
</ul>
<div (click)="onDivClick()">
<button class="btn btn-primary" [class.active]="isActive" (click)="onClick($event)">Create</button>
</div>
`,
providers: [CourseService],
directives: [AutoGrowDirective]
})
export class CoursesComponent {
title = 'The title of courses page';
courses: string[];
isActive = true;
constructor(courseService: CourseService) {
this.courses = courseService.getCourses();
}
onClick($event){
$event.stopPropagation();
console.log('Clicked', $event);
}
onDivClick($event){
console.log('On Div Clicked', $event);
}
}
Self-closing elements are not correctly parsed by Angular 2 and not planned on be implemented.
That's why you have to close all tags correctly:
From the Github Issue:
i
tag isn't self closing tag, you have to close it manually. You forgot to close<i>
tag which is messing up withli
as well & confusingngFor
directive whereli
has ended.Template