如何在Angular2中为模板的一部分禁用模板绑定?

时间:2016-04-24 10:04:23

标签: angular angular2-template

我想在Angular 2模板中显示{{ name }}字符串。

如何禁用部分模板的模板绑定?

2 个答案:

答案 0 :(得分:3)

ngNonBindable属性添加到标记中,然后Angular不处理绑定。

Plunker example

答案 1 :(得分:2)

Angular 4/5的更新。 现在,打印角度模板中的{符号:

 {{ '{' }}

ng serve out Error showing up the correct way

我的package.json:


        {
      "name": "angular-client",
      "version": "0.0.0",
      "description": "My Angular Client",
      "author": "noone",
      "copyright": "",
      "license": "UNLICENSED",
      "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@angular/common": "^4.4.6",
        "@angular/compiler": "^4.4.6",
        "@angular/core": "^4.4.6",
        "@angular/forms": "^4.4.6",
        "@angular/http": "^4.4.6",
        "@angular/platform-browser": "^4.4.6",
        "@angular/platform-browser-dynamic": "^4.4.6",
        "@angular/router": "^4.4.6",
        "@angular/upgrade": "^4.4.6",
        "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
        "chart.js": "^2.5.0",
        "core-js": "^2.4.1",
        "file-saver": "^1.3.3",
        "lodash": "^4.17.4",
        "moment": "^2.18.1",
        "ng2-charts": "^1.5.0",
        "ng2-currency-mask": "^4.3.1",
        "ng2-slim-loading-bar": "^4.0.0",
        "ngx-bootstrap": "^1.9.3",
        "rxjs": "^5.3.0",
        "stacktrace-js": "^2.0.0",
        "ts-helpers": "^1.1.2",
        "zone.js": "^0.8.8"
      },
      "devDependencies": {
        "@angular/cli": "^1.0.2",
        "@angular/compiler-cli": "^4.4.6",
        "@types/jasmine": "^2.5.47",
        "@types/node": "^7.0.13",
        "codelyzer": "^2.1.1",
        "jasmine-core": "^2.5.2",
        "jasmine-spec-reporter": "^3.2.0",
        "karma": "^1.6.0",
        "karma-chrome-launcher": "^2.0.0",
        "karma-cli": "^1.0.1",
        "karma-coverage-istanbul-reporter": "^1.2.0",
        "karma-jasmine": "^1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",

        "protractor": "^5.1.1",


        "ts-node": "^3.0.2",
        "tslint": "^4.5.1",
        "typescript": "^2.2.2"
      }
    }