Angular 角度2 ngIf意外标记#

Angular 角度2 ngIf意外标记#,angular,components,angular-ng-if,Angular,Components,Angular Ng If,大家好,我正在学习angular2,现在我正在与*ngIf合作,我有这个代码 <div *ngIf='courses.length > 0 ; then #coursesList else #noCourses'> </div> <ng-template #coursesList> <h1>List of courses</h1> </ng-template> <ng-template #noCourses&

大家好,我正在学习angular2,现在我正在与
*ngIf
合作,我有这个代码

<div *ngIf='courses.length > 0 ; then #coursesList else #noCourses'>
</div>
<ng-template #coursesList>
  <h1>List of courses</h1>
</ng-template>
<ng-template #noCourses>
  <h2>No courses yet</h2> 
</ng-template>
我的问题是在运行网站时出现以下错误:

Uncaught Error: Template parse errors:
Parser Error: Unexpected token # at column 27 in [courses.length > 0 ; then 
#coursesList else #noCourses] in ng:///AppModule/AppComponent.html@1:5 ("
<h1>Angular</h1>
<div [ERROR ->]*ngIf='courses.length > 0 ; then #coursesList else 
#noCourses'>
</div>
"): ng:///AppModule/AppComponent.html@1:5
未捕获错误:模板分析错误:
分析器错误:在[courses.length>0中的第27列出现意外标记#;然后
#ng:///AppModule/AppComponent中的课程列表else#noCourses]。html@1:5 ("
有棱角的
]*ngIf='courses.length>0;然后#coursesList else
#无课程'>
“”:ng:///AppModule/AppComponent。html@1:5
我不明白为什么我要遵循“不想使用复制粘贴”中的指南,因为我需要知道为什么会发生这种情况

您需要删除
课程列表
无课程
前面的#仅在ng模板标记上使用

<div *ngIf='courses.length > 0 ; then coursesList else noCourses'>
</div>

<div *ngIf='courses.length > 0 ; then coursesList else noCourses'>
</div>