繁体   English   中英

我在 angular:src/app/app.component.html:18:20 上收到此错误 - 错误 TS2339:“AppComponent”类型上不存在属性“DepScreen”

[英]I am getting this error on angular:src/app/app.component.html:18:20 - error TS2339: Property 'DepScreen' does not exist on type 'AppComponent'

这是我的 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>

我得到的错误是:

编译失败。

src/app/app.component.html:18:20 - 错误 TS2339:“AppComponent”类型上不存在属性“DepScreen”。

18(点击)="DepScreen=true; EmpScreen=false;">~~~~~~~~~

src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:18:36 - 错误 TS2339:“AppComponent”类型上不存在“EmpScreen”属性。

18(点击)="DepScreen=true; EmpScreen=false;">~~~~~~~~~

src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:22:20 - 错误 TS2339:“AppComponent”类型上不存在“DepScreen”属性。

22(点击)="DepScreen=false;EmpScreen=true;">员工~~~~~~~~~

src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:22:36 - 错误 TS2339:“AppComponent”类型上不存在“EmpScreen”属性。

22(点击)="DepScreen=false;EmpScreen=true;">员工~~~~~~~~~

src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:27:28 - 错误 TS2339:“AppComponent”类型上不存在“DepScreen”属性。

27 <app-department *ngIf="DepScreen"> ~~~~~~~~~

src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。 src/app/app.component.html:28:26 - 错误 TS2339:“AppComponent”类型上不存在属性“EmpScreen”。

28 <app-employee *ngIf="EmpScreen"> ~~~~~~~~~

src/app/app.component.ts:5:16 5 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。

究竟是什么问题,我该如何解决?

您是否在 Class AppComponent 下的 app.component.ts 中声明了 EmpScreen 和 DepScreen? 像这样的东西: EmpScreen: boolean = false; DepScreen:boolean = 假;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM