How to avoid curly braces to display on a page when using AngularJS?

I want the user to see double curly braces, but Angular ties them automatically. This is the opposite case of this question , where they do not want to see the curly braces used to snap when loading the page.

I want the user to see this:

My name is {{person.name}}. 

But Angular replaces {{person.name}} with a value. I thought this might work, but Angular is still replacing it with a value:

 {{person.name}} 

Plunker: http://plnkr.co/edit/XBJjr6uR1rMAg3Ng7DiJ

+71
angularjs
Jun 01 '13 at 1:01
source share
5 answers
 <code ng-non-bindable>{{person.name}}</code> 

Documentation @ http://docs.angularjs.org/api/ng.directive:ngNonBindable

+128
Jun 01 '13 at 1:44
source share

Edit: append \ slash between brackets inside quotes

 {{ "{{ person.name }\}" }} 

this too .. passages angular interpretation

 {{ person.name }<!---->} 

it is too..

 {{ person.name }<x>} {{ person.name }<!>} 
+17
Feb 16 '15 at 23:26
source share

In our case, we wanted to represent curly braces in the placeholder, so they should appear inside the HTML attribute. We used this:

  <input placeholder="{{ 'Hello {' + '{person.name}' + '}!' }}" ...> 

As you can see, we create a line of three smaller lines to keep the braces separate.

 'Hello {' + '{person.name}' + '}!' 

This avoids the use of ng-non-bindable , so we can continue to use the ng- attributes ng- on the element.

+7
May 27 '16 at 2:30
source share
 <span>{{</span>{{variable.name}}<span>}}</span> 
+1
Sep 14 '17 at 11:57
source share

Use ng-non-bindable in the container, this affects the entire container inside the container.

 <div ng-non-bindable> <span>{{person.name}}</span> <img src="#" alt="{{person.name}}"> <input placeholder="{{person.name}}"> </div> 
0
Feb 28 '17 at 14:21
source share



All Articles