我回到了一个古老的AngularJS项目(1.7.2),使用了角度翻译,我正在与ng-bind-html
进行斗争。
在我的HTML中我写了这个
<span ng-bind-html="'LEFT_PANEL.VISITED_AFTER' | translate"></span>
我期待的结果是
<span>Visited <strong>after</strong> this date. </span>
我的翻译文件包含:
"VISITED_AFTER": "Visited <strong>after</strong> this date"
我实际得到的是:
<span ng-bind-html="'LEFT_PANEL.VISITED_BEFORE' | translate" class="ng-binding ng-scope">
Visited <strong>before</strong> this date
</span>
我做错了什么?
(是的,我的模块中有ngSanitize
)
由于
答案 0 :(得分:1)
NgTranslate正在使用它自己的Sanitizer(Docs)
要全局更改清理策略,请使用$translateProvider.useSanitizeValueStrategy("STRATEGY");
如果您只想为此元素设置不同的策略,请使用属性translate-sanitize-strategy
答案 1 :(得分:0)
this可能重复。
似乎与HTML解码有关。 添加此功能:
decodeHtml(...)
并围绕您正在打印的内容:import math
from PyQt5.QtWidgets import QWidget, QApplication, QGraphicsScene
from PyQt5.QtGui import QPainter, QColor, QBrush, QPen
from PyQt5.QtCore import Qt
import sys
import xlrd
import time
class Heads_ups(QWidget):
lineno=0
pitch,roll=[],[]
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(300,300,480,360)
self.setWindowTitle('Colours')
self.show()
def read_file(self,lineno):
withopen('text file having rows and columns','r',) as f :
lines = f.readlines()[4:]
for s in lines:
a = s.split()
#print (len(a))
if(len(a)!=14):
print("point reached")
lineno += 1
continue
self.pitch.append(float(a[4]))
self.roll.append(float(a[6]))
lineno += 1
# print(lineno)
return lineno
def counterrotate(self,origin,point1,roll):
ox,oy = origin
px,py = point1
angle=math.radians(roll)
#counterclockwise
qx= ox+ math.cos(angle)*(px-ox)-math.sin(angle)*(py-oy)
qy= oy+ math.sin(angle)*(px-ox)+math.cos(angle)*(py-oy)
return qx,qy
def rotate(self,origin,point,roll):
ox,oy = origin
px,py = point
angle=math.radians(roll)
#clockwise
qx= ox+ math.cos(angle)*(px-ox)+math.sin(angle)*(py-oy)
qy= oy+ math.sin(angle)*(px-ox)+math.cos(angle)*(py-oy)
return qx,qy
def paintEvent(self,e):
# print(filename)
qp= QPainter(self)
qp.begin(self)
self.drawLine(qp)
self.update()
self.move_line(qp)
qp.end()
def drawLine(self,qp):
pen= QPen(Qt.black,2,Qt.SolidLine)
qp.setPen(pen)
qp.drawLine(0,180,480,180)
self.update()
QApplication.processEvents()
time.sleep(0.2)
def move_line(self,qp):
pen=QPen(Qt.green,2,Qt.SolidLine)
qp.setPen(pen)
qp.drawLine(0,180+50,480,180+50)
# self.scene=QGraphicsScene(self)
lineno = self.read_file(self.lineno)
for m in range(0,lineno,1):
x0=-400
x1=880
y0=180
y1=180
xc=240
yc=180
point=(x0,y0)
point1= (x1,y1)
origin= (xc,yc)
x0,y0=self.rotate(origin,point,self.roll[m]*10)
y0=y0-(self.pitch[m]*60)
# canvas.move(point,x0,y0)
x1,y1=self.counterrotate(origin,point1,self.roll[m]*10)
y1=y1-(self.pitch[m]*60)
dlt=qp.drawLine(x0,y0,x1,y1)
self.update()
QApplication.processEvents()
time.sleep(0.5)
# self.scene.removeItem(dlt)
if __name__ == '__main__':
app=QApplication(sys.argv)
hp=Heads_ups()
filename=open('textfile having rows and columns','r')
sys.exit(app.exec_())
实际上只看这个plunkr