I have a weird problem. I have a simple textarea, Once a save button is clicked I save that data using an angular controller. Then once an update button is clicked I update a row in that data base, that one of that rows fields is the data from that textarea.

我有个奇怪的问题。我有一个简单的textarea,一旦单击save按钮,我将使用一个角度控制器保存数据。点击更新按钮后,我更新数据库中的一行,其中一个行字段就是来自该textarea的数据。

So far so good, and the update is done ok, the problem begins when I break lines in the textarea, for example, I type: "Hi guys, This is another row"

到目前为止,一切都很好,更新也完成了,问题开始了当我在textarea中中断行,例如,I类型:“嗨,伙计们,这是另一行”

I checked that data and when I save it in the controller, and when I get it back from the server it looks like this: "Hi guys,↵This is another row" seems ok, but when I place it inside a div I get the following: "Hi guys,This is another row"

我检查数据,当我将它保存在控制器,当我把它从服务器是这样的:“嗨,伙计们,↵这是另一个行”似乎是好了,但是当我把它在一个div我得到以下:“嗨,伙计们,这是另一个行”

Where did the line break go? and why is it not displaying?

断线在哪里?为什么它不显示?

I tried bunch of things, like changing the newline to <br> once send to the database, later on switching it back to newline, nothing seems to work...

我尝试了很多方法,比如将换行符改为
,一旦发送到数据库,然后将它切换回换行符,似乎没有任何效果……

Any help would be appreciated.

如有任何帮助,我们将不胜感激。

3 个解决方案

#1


3

Okay - what you need to do is use white-space:pre-wrap; where you display the data from the database.

好的,你需要做的是使用空白:预包装;显示来自数据库的数据。

Example:

例子:

<?php
echo '<p style="white-space:pre-wrap;">'.$yourVarWithWhiteSpace.'</p>';
?>

更多相关文章

  1. 使用jQuery导出JSON(外部文件)导入数据的度假输出
  2. 我应该如何显示包含XML数据源的表?
  3. 只有在读取数据库后才选择(案例)(开关)
  4. 将JavaScript函数的值插入SQL Server数据库
  5. js中ajax获取json数据遍历提示undefined
  6. JS数据类型(一)
  7. 在单页中使用ajax和php上传多个表单数据
  8. 在phonegap上从服务器获取数据
  9. javascript 数据类型转换

随机推荐

  1. LeetCode数据库篇|181超过经理收入的员工
  2. Scrapy爬虫实战| 手把手教你使用CrawlSpid
  3. 520|解锁Python表白新姿势
  4. Android(安卓)Studio真机测试时生成的程
  5. Python办公自动化|批量处理文件,一学就会
  6. 想做疫情分析却没有数据?看这篇就够了
  7. Python办公自动化|光速对比并提取两份Word
  8. Selenium自动化|爬取公众号全部文章,就是这
  9. Python办公自动化|自动更新表格,告别繁琐
  10. 收藏| Scrapy框架各组件详细设置