angularjs - 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.
解决方案
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 }}" />
推荐阅读
- elasticsearch - EFK Stack(Elasticsearch、Fluent-bit、Kibana)设置不显示 Kubernetes 字段
- java - 在后台Android应用程序中获取键盘按键
- r - 使用 dplyr::case_when 时右手边的按行 min()
- python - Xgboost 随机种子设置不能确保再现能力
- android - 后台堆栈中的片段会发生什么?
- python - Keras - NN 预测计量测量中的误差。
- android - Android TV Leanback 应用程序作为默认启动器
- javascript - 使用 JavaScript 每 60 秒自动刷新一次页面
- node.js - 在节点 js 中创建读取流以获取 favicon.ico 而不是文件
- mysql - Excel Mac 2016,在 VBA 函数中调用时 ListObject 不起作用