角用法“!”符号

时间:2019-05-10 11:31:41

标签: javascript angular typescript angular-cli angular7

我正在编辑用角度6编写的项目的一些代码,将项目升级到角度7后,我遇到了有关使用此“!”的一些问题!组件的html文件中的符号。

    <div *ngIf="parentField == null">
          <a href (click)="!!setEntity(entity)">{{ entity.name }}</a>
   </div>

如您在上方看到的,使用了“!”登录我的模板。我不知道它的含义或对该符号对我的组件的影响。如果我删除了这些符号,则该应用会以开发模式重新加载自身。

在生产模式下编译它时,还会引发此错误。

An expression of type 'void' cannot be tested for truthiness

请参见下面我更新的依赖项

dependencies": {
    "@angular/animations": "^7.2.15",
    "@angular/cdk": "^7.2.0",
    "@angular/common": "^7.2.15",
    "@angular/compiler": "^7.2.15",
    "@angular/core": "^7.2.15",
    "@angular/forms": "^7.2.15",
    "@angular/material": "^7.2.0",
    "@angular/platform-browser": "^7.2.15",
    "@angular/platform-browser-dynamic": "^7.2.15",
    "@angular/router": "^7.2.15",
    "@fortawesome/fontawesome-free-brands": "^5.0.13",
    "@fortawesome/fontawesome-free-regular": "^5.0.13",
    "@fortawesome/fontawesome-free-solid": "^5.0.13",
    "@handsontable/angular": "^3.0.0", 
    "core-js": "^2.5.4", 
    "ngx-bootstrap": "^3.0.0",
    "npm": "^5.6.0", 
    "rxjs": "^6.5.2", 
    "zone.js": "^0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.11.4",
    "@angular/cli": "~7.3.9",
    "@angular/compiler-cli": "^7.2.15",
    "@angular/language-service": "^7.2.15",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "angular-ide": "^0.9.55",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.2",
    "ts-node": "^7.0.0",
    "tslint": "^5.11.0",
    "typescript": "~3.2.4"
  }

等待您的帮助!

0 个答案:

没有答案