为什么在AngularJS应用程序中空白会被忽略 [英] why white space are getting ignored in AngularJS application

查看:66
本文介绍了为什么在AngularJS应用程序中空白会被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AngularJS应用程序:

AngularJS application:

ng-model指令将输入字段绑定到控制器属性.在我的应用程序中,带空格的输入被忽略,例如:" A",结果输出为"A".

The ng-model directives bind the input fields to the controller properties.In my application the inputs with spaces are ignored, for example : " A",the resulting output is "A".

是否也可以包含这些空白?

Is there a way to include those white spaces as well ?

此处

谢谢

推荐答案

您可以将ng-trim="false"属性添加到除此之外,还存在另一个问题,即空白不是用HTML呈现的..

Besides that, you also have the additional problem that the whitespace isn't rendered in HTML.

例如,您可以通过使用

Full Name: <pre>{{Location + " " + Item}}</pre>

演示小提琴

或者使用CSS:

white-space: pre;

演示小提琴

这篇关于为什么在AngularJS应用程序中空白会被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆