页 - 不found.component.ts
import { FormsModule, NgModel } from '@angular/forms';
import { ChangeDetectorRef, Component, ElementRef, OnInit, Renderer2, ViewChild, ViewEncapsulation } from '@angular/core';
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { element } from 'protractor';
import { SplitButtonModule } from "primeng/primeng";
import { Router } from '@angular/router';
@Component({
selector: 'app-page-not-found',
templateUrl: './page-not-found.component.html',
styleUrls: ['./page-not-found.component.css']
})
export class PageNotFoundComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
page-not-found.component.html
<p *ngif=true>
page-not-found works!
</p>
问题是*ngif
无效。我重新启动了系统并清除了缓存。我收到以下错误:
Uncaught Error: Template parse errors: Property binding ngif not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("[ERROR->]<p *ngif=true> page-not-found works! </p>
答案 0 :(得分:0)
请使用:
<p *ngIf="true">
page-not-found works!
</p>
*ngIf
不正确*ngif
答案 1 :(得分:0)
每当你有像* ngIf,[value =]或(改变)这样的角度语法时,方程式的另一端应该用引号括起来。这告诉angular要在组件中查找您的值。因此,我建议您在组件中放置一个字段,如下所示:
truthy = true;
然后:
<p *ngIf="truthy">
page-not-found works!
</p>
如果你不用引号括起来,它会假定它是一个字符串文字,并且可能不会给你你想要的结果。