首页 > 解决方案 > How to disable (or escape) interpolation in a DOM attribute?

问题描述

I need to show the curly brace notation to the user, as input value. Also the user should be able to type curly braces to the input. I need to get the value with the curly braces.

I can't use ng-non-bindable expression because I need to get the value from the input. I tried something like this but I got a lexer error:

<input value="{{ '{{ first_name }}' }}">

I want to put {{ first_name }} as the default input value.

标签: angularjs

解决方案


Use binding with the model, and place whatever value you want in the model. For example:

<input ng-model="person.firstName" />

where model.firstName is the value you want.

Or

<input placeholder="{{ model.placeholder }}" />

推荐阅读