角度表达式为{{ notification.noti_val }}
。 存储在表达式中的值是saha like own wall
。如何删除角色js中的 ?
如何删除
字符?
角度表达式为{{ notification.noti_val }}
。 存储在表达式中的值是saha like own wall
。如何删除角色js中的 ?
如何删除
字符?
您需要将您的值指定为安全的html。在角度上,你可以使用$sce
服务来做到这一点。我创建了这个jsbin解释用例,它修复了你的问题
在控制器中声明的{{trustAsHtml(notification.noti_val)}}}服务:app.controller('NotificationCtrl',function($ scope,$ http,$ ionicLoading,$ state,$ stateParams, $ ionicPopup,profile, $ sce){.....里面的控制器:$ scope.trustAsHtml = function(notificationText){ return $ sce.trustAsHtml(notificationText); };仍然显示ujjal saha &nb sp; share &nb sp; own &nb sp; wall;注意添加nb和sp之间的空间由于网站格式化 – WebInsight
好吧,它已经稍微改变了html格式为jsbin中的一个,但工作。谢谢。 – WebInsight
你试过'str.replace(/&nb sp/g,“”);' – mkHun
我做了这个{{notification.noti_val.replace(/&nb sp/g,“”);}}但得到像错误一样的错误:[$ parse:lexerr] Lexer错误:列31-31中出现意外的下一个字符[&] [notification.noti_val.replace(/&nb sp/g ,“”);]。在nb和sp之间没有空格。我这样做是因为该网站显示为空间 – WebInsight
尝试转义'&'。 '(/ \ /g,'')' – Lex