Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable template binding in for part of template in Angular2?

I would like to display {{ name }} string in Angular 2 template.

How do I disable template binding for part of template?

like image 462
tomaszbak Avatar asked Apr 24 '16 10:04

tomaszbak


2 Answers

Add the ngNonBindable attribute to the tag, then Angular doesn't process bindings.

Plunker example

like image 159
Günter Zöchbauer Avatar answered Oct 31 '22 19:10

Günter Zöchbauer


Update for Angular 4/5. Now, for printing { symbol inside angular template:

 {{ '{' }}

ng serve out Error showing up the correct way

My 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"
      }
    }

like image 23
r0b3rt0 Avatar answered Oct 31 '22 19:10

r0b3rt0