angularjs给文本赋值保留换行符br的方法

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/x18094/article/details/84590368

场景:后台放回一串数据带有换行符 <br />,使用angularjs的时候,它会把换行符直接显示储来,不会换行。

解决方法:html标签增加

ng-bind-html="mycontent"
<div ng-bind-html="mycontent" style="margin-left: 280px;margin-right: 280px"></div>

 js代码中引入:$sce

app.controller('myCon1', ["$scope", "$http", "$filter", "NgTableParams","$sce", function ($scope, $http, $filter, NgTableParams,$sce) {
      ...省略

  $scope.mycontent= $sce.trustAsHtml(response.data);
   ...

ok,成功实现换行。

展开阅读全文

一个BR换行符问题...

08-27

目前验证码、验证码输入框式和提交按钮(登录)是在同一行。我想让登录按钮在验证码输入框的下方请问如何改?rn还有我要改动用户名和密码输入框的大小应该怎么写?rnrn[code=VBScript]rn<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>rn rn<%WSOASCOMSTR=" "rnaction=request("action")rnif action<>"loginout" thenrn if WS_S.HX_ISLogin then RESPONSE.Write " ":response.Endrnend ifrnSelect Case actionrn Case "checklogin"rn WS_S.ChkIsOuter:HX_UserName=Replace(Request.Form("HX_UserName"),"'","''"):HX_PassWord=Replace(Request.Form("HX_PassWord"),"'","''"):HX_ValidateCode=Replace(Request.Form("HX_ValidateCode"),"'","''"):HX_cook=HX_Checknum(Request.Form("cook"))rn If HX_ValidateCode<>Session("HX_GetCode") then HX_GoBack "验证错误,请重新填写!",""rn tablename="HX_CompanyUser": Orderby=" where WS_UserName='"&HX_UserName&"' and WS_PassWord='"&md5(HX_PassWord)&"'"rn call WS_S.ChecKIPlock(Request.ServerVariables("REMOTE_ADDR"))rn SET RS=WS_S.HX_SetRSD(Cols,tablename,Orderby)rn IF RS.RECORDCOUNT>0 THENrn if rs("WS_leave")="True" then call WS_S.SaveAdminLog(HX_UserName,rs("WS_Appointment"),"登录失败!等待审核"):call HX_GoBack("请等待审核!","")rn WS_Uid=rs("WS_Uid"):WS_UserName=rs("WS_UserName"):WS_Appointment=rs("WS_Appointment"):WS_department=rs("WS_department")rn Set Onrs=WS_S.HX_SetRSD(Cols,"HX_Online"," where WS_Userid="&WS_Uid)rn if Onrs.recordcount>0 thenrn if RS("WS_LoginIn")=1 thenrn RS("WS_LoginIn")=0:RS.updatern session("WSOASCOM")="shoppescn"rn else rn RS("WS_LoginIn")=1:RS.updatern session("WSOASCOM")="shoppescn"rn end ifrn WS_S.HX_SelectCookiesORSessionrn elsern RS("WS_LoginIn")=1:RS.update:WS_S.HX_SelectCookiesORSessionrn Onrs.addnew:Onrs("WS_Userid")=WS_Uid:Onrs("WS_Name")=RS("WS_Name"):Onrs("WS_Viewip")=Request.ServerVariables("REMOTE_ADDR"):Onrs("WS_Lasttime")=now:Onrs.updatern end ifrn WS_S.HX_RSClose Onrs: call WS_S.SaveAdminLog(WS_UserName,WS_Appointment,"登录成功!"):WS_S.HX_Redirect "HX_managemain.asp"rn elsern call WS_S.SaveAdminLog(HX_UserName,0,"登录失败!尝试用户名和密码为: 用户名:"&HX_UserName&" 密码:"&HX_PassWord&""):HX_GoBack "用户名或密码错误,请重新填写!",""rn END IFrn WS_S.HX_RSClose RS rn Case "loginout":if request.Cookies(prefix)("LOGINUSERNAME")<>"" and request.Cookies(prefix)("logAppointment")<>"" then call WS_S.SaveAdminLog(request.Cookies(prefix)("LOGINUSERNAME"),request.Cookies(prefix)("logAppointment"),"成功注销!"):Call WS_S.HX_LoginOut():HX_GoBack "成功注销!","HX_Login.asp"rnEnd SelectrnWSOASCOMSTR=WSOASCOMSTR&" rn "rnWSOASCOMSTR=WSOASCOMSTR&" rn 用户名:"rnWSOASCOMSTR=WSOASCOMSTR&" 密 码: 验证码: "rnWSOASCOMSTR=WSOASCOMSTR&" rnWSOASCOMSTR=WSOASCOMSTR&""rn "rnresponse.Write WSOASCOMSTR%>rn[/code] 论坛

没有更多推荐了,返回首页