3
大家好我是研究angular2现在IM workind与*ngIf
和我有这样的代码角2 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>
而这是我component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'app hello';
courses=[];
}
我的问题,当我运行网站我有这个错误:
Uncaught Error: Template parse errors:
Parser Error: Unexpected token # at column 27 in [courses.length > 0 ; then
#coursesList else #noCourses] in ng:///AppModule/[email protected]:5 ("
<h1>Angular</h1>
<div [ERROR ->]*ngIf='courses.length > 0 ; then #coursesList else
#noCourses'>
</div>
"): ng:///AppModule/[email protected]:5
我不明白为什么我fo在不想使用复制粘贴的指导中,因为我需要知道为什么会发生这种情况