Javascript 处理及;在数据绑定期间插入数据

Javascript 处理及;在数据绑定期间插入数据,javascript,angularjs,Javascript,Angularjs,有一个绑定到文本框的名称字段。一切正常。 现在,当有人输入unicode字符时,它将转换为html元素。 在页面重新加载时,输入框中的名称显示html元素。不应该是这样! 你怎么解决这个问题 <input placeholder='Name' type="text" ng-model="form.firstName" ng-required="true" /> name = health &amp; wealth textbox = health &amp; wea

有一个绑定到文本框的名称字段。一切正常。 现在,当有人输入unicode字符时,它将转换为html元素。 在页面重新加载时,输入框中的名称显示html元素。不应该是这样! 你怎么解决这个问题

<input placeholder='Name' type="text" ng-model="form.firstName" ng-required="true" />

name = health &amp; wealth
textbox = health &amp; wealth
required in textbox = health & wealth

您可以使用过滤器对其进行格式化

<input placeholder='Name' type="text" ng-model="form.firstName | html" ng-required="true" />
最后,别忘了将这个过滤器添加到模块中

angular.module("app", ['formatFilters'])

我在加载数据时做了类似的事情&在做任何事情之前。谢谢你的回答。
angular.module("app", ['formatFilters'])