[英]I am getting this error on angular:src/app/app.component.html:18:20 - error TS2339: Property 'DepScreen' does not exist on type 'AppComponent'
This is my app.component.html code这是我的 app.component.html 代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="container">
<h3 class="d-flex justify-content-center">Angular 8 with Web API Demo</h3>
<h5 class="d-flex justify-content-center">Employee Management Portal</h5>
<nav class="navbar navbar-expand-sm bg-light navbar-dark">
<ul class="navbar-nav">
<li class="nav-item">
<button class="m-1 btn btn-light btn-outline-primary" Button
name="DepScreen"
(click)="DepScreen=true; EmpScreen=false;">
Department</button>
<button class="m-1 btn btn-light btn-outline-primary" Button
name="EmpScreen"
(click)="DepScreen=false;EmpScreen=true;">Employees</button>
</li>
</ul>
</nav>
<app-department *ngIf="DepScreen"></app-department>
<app-employee *ngIf="EmpScreen"></app-employee>
</div>
</body>
</html>
And the error I am getting is:我得到的错误是:
Failed to compile.编译失败。
src/app/app.component.html:18:20 - error TS2339: Property 'DepScreen' does not exist on type 'AppComponent'. src/app/app.component.html:18:20 - 错误 TS2339:“AppComponent”类型上不存在属性“DepScreen”。
18 (click)="DepScreen=true; EmpScreen=false;"> ~~~~~~~~~ 18(点击)="DepScreen=true; EmpScreen=false;">~~~~~~~~~
src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component AppComponent. src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:18:36 - error TS2339: Property 'EmpScreen' does not exist on type 'AppComponent'. src/app/app.component.html:18:36 - 错误 TS2339:“AppComponent”类型上不存在“EmpScreen”属性。
18 (click)="DepScreen=true; EmpScreen=false;"> ~~~~~~~~~ 18(点击)="DepScreen=true; EmpScreen=false;">~~~~~~~~~
src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component AppComponent. src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:22:20 - error TS2339: Property 'DepScreen' does not exist on type 'AppComponent'. src/app/app.component.html:22:20 - 错误 TS2339:“AppComponent”类型上不存在“DepScreen”属性。
22 (click)="DepScreen=false;EmpScreen=true;">Employees ~~~~~~~~~ 22(点击)="DepScreen=false;EmpScreen=true;">员工~~~~~~~~~
src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component AppComponent. src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:22:36 - error TS2339: Property 'EmpScreen' does not exist on type 'AppComponent'. src/app/app.component.html:22:36 - 错误 TS2339:“AppComponent”类型上不存在“EmpScreen”属性。
22 (click)="DepScreen=false;EmpScreen=true;">Employees ~~~~~~~~~ 22(点击)="DepScreen=false;EmpScreen=true;">员工~~~~~~~~~
src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component AppComponent. src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:27:28 - error TS2339: Property 'DepScreen' does not exist on type 'AppComponent'. src/app/app.component.html:27:28 - 错误 TS2339:“AppComponent”类型上不存在“DepScreen”属性。
27 <app-department *ngIf="DepScreen"> ~~~~~~~~~ 27 <app-department *ngIf="DepScreen"> ~~~~~~~~~
src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component AppComponent. src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:28:26 - error TS2339: Property 'EmpScreen' does not exist on type 'AppComponent'. src/app/app.component.html:28:26 - 错误 TS2339:“AppComponent”类型上不存在属性“EmpScreen”。
28 <app-employee *ngIf="EmpScreen"> ~~~~~~~~~ 28 <app-employee *ngIf="EmpScreen"> ~~~~~~~~~
src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component AppComponent. src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。
What is the issue exactly and how can I solve it?究竟是什么问题,我该如何解决?
have you declared EmpScreen and DepScreen in your app.component.ts under Class AppComponent?您是否在 Class AppComponent 下的 app.component.ts 中声明了 EmpScreen 和 DepScreen? Something like this: EmpScreen: boolean = false;像这样的东西: EmpScreen: boolean = false; DepScreen: boolean = false; DepScreen:boolean = 假;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.