简体   繁体   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'

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.

相关问题 app / app.component.ts(192,17):错误TS2339:类型&#39;Intercom&#39;不存在属性&#39;init&#39; - app/app.component.ts(192,17): error TS2339: Property 'init' does not exist on type 'Intercom' 为什么我在 querySelectorAll 上收到错误 TS2339 for checkbox property &#39;checked&#39; 不存在 - Why am I getting error TS2339 on querySelectorAll for checkbox property 'checked' does not exist 错误TS2339:类型“字符串”上不存在属性“默认”。** - Error TS2339: Property 'Default' does not exist on type 'string'.** 错误TS2339:类型“ HTMLElement”上不存在属性“ imageID” - error TS2339: Property 'imageID' does not exist on type 'HTMLElement' 错误TS2339:类型“ {}”上不存在属性“ forEach” - error TS2339: Property 'forEach' does not exist on type '{}' 错误TS2339:类型“ HTMLElement”上不存在属性“名称” - error TS2339: Property 'name' does not exist on type 'HTMLElement' 错误 TS2339:“温度”类型上不存在属性“摄氏度” - error TS2339: Property 'celsius' does not exist on type 'Temperature' 错误 TS2339:“特殊 []”类型上不存在属性“默认” - Error TS2339: Property 'default' does not exist on type 'Special[]' 角度6:错误TS2339:类型“ HTMLElement”上不存在属性“值” - Angular 6: error TS2339: Property 'value' does not exist on type 'HTMLElement' Angular2打字稿错误TS2339:类型“ Y”上不存在属性“ x” - Angular2 typescript error TS2339: Property 'x' does not exist on type 'Y'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM