Sray
Sray

Reputation: 685

Angularjs display expression in curly braces as text

I need to display some text on the page which looks exactly as Angularjs expression in curly braces:

{{some_text}} 

But this is just a text and should not denote bindings. Unfortunately, I cannot modify this text somehow so need to solve this particular issue.

This text is echo'ed by the means of php on the page and is showing inside ng-controller section.

I will appreciate any ideas.

Thank you in advance.

Upvotes: 1

Views: 1069

Answers (2)

Vaibhav Magon
Vaibhav Magon

Reputation: 1503

ngNonBindable directive Is a definite solution. As shown Below.

<div>Normal: {{1 + 2}}</div>
<div ng-non-bindable>Ignored: {{1 + 2}}</div>

Upvotes: 1

gkalpak
gkalpak

Reputation: 48211

You could change the $interpolateProvider's start- and end-symbols (e.g. instead of {{ and }}, you could set them to {[ and ]} (or whatever)).

Alternatively, you could put it inside an element with the ngNonBindable directive, which Angular won't touch (this is probably the best option if there are no other constraints or requirements prohibiting it).


BTW, v1.3.0-beta.10 introduced a way to escape the start- and end-symbols (e.g. something like \\{\\{ \\}\\}) and there is a lengthy discussion regarding the reasoning of such a feature (and several work-arounds) here.

Upvotes: 3

Related Questions