应用&LT;强&GT;标签为一个字符串在我js.coffee文件 [英] Apply <strong> tags to a string in my js.coffee file
问题描述
我目前使用的角度和斯利姆在我的Ruby on Rails项目。我有我的js.coffee目前正在在我看来呈现问题的数组。
一个数组中的字符串具有较强的标签,但它没有被我的HTML正确显示。
非但没有的标准后,我得到这个...
在这操场是在&lt;强而GT;标LT; / STRONG&GT;比赛打了?
我是相当新的角度,我错过什么?
JAVASCRIPT
game_create_ctrl.js.coffeeangular.module('OombangularApp')。控制器GameCreateCtrl',[
'$范围,$ SCE,$ uibModal','游戏','GameFormat','PlayfieldType','女神',
($范围,SCE $,$ uibModal,游戏,GameFormat,PlayfieldType,假面) - GT; $ scope.step = 1 ###这工作...当它不是一个数组
$ scope.html =在这操场是+&LT;强&GT;标LT; / STRONG&gt;中+比赛打了?
$ scope.stepQuestion = $ sce.trustAsHtml($ scope.html) ###如何显示在&lt;强而GT;在我看来标签时,其阵列? $ scope.stepQuestions = ['你应该这样游戏叫?,我应该这游戏叫?,
这是否属于游戏类什么来?,
在这操场是在&lt;强而GT;标LT; / STRONG&GT;比赛打了?,
什么是播放器配置?,如何是一个&LT;强&GT;标LT; / STRONG&GT;比赛赢了吗?,哪个女神拥有这个游戏?]] $ scope.stepQuestions = $ scope.stepQuestions.map(项目) - &GT; $ sce.trustAsHtml(项目)
正文
new.html.slim形式[名称='gameCreateForm'NG控制器='GameCreateCtrl'] ###这个工程
NG。提问绑定-HTML =stepQuestion{{stepQuestion}} ###这并不
NG。提问绑定-HTML =stepQuestions{{stepQuestions [一步 - 1]}}
请尝试:
<一href=\"http://stackoverflow.com/questions/17289448/angularjs-to-output-plain-text-instead-of-html\">angularjs输出纯文本,而不是HTML (类似的问题)
或 https://docs.angularjs.org/api/ng/directive/ngBindHtml
I am currently using Angular and Slim in my Ruby On Rails Project. I have an array of questions in my js.coffee that are currently being rendered in my view.
One of the strings in the array has strong tags, but it is not being displayed properly in my html.
Instead of getting Standard, I get this...
On which Playfield is the <strong>Standard</strong> game played ?
I am fairly new to angular, what am I missing?
JAVASCRIPT
game_create_ctrl.js.coffee
angular.module('OombangularApp').controller 'GameCreateCtrl', [
'$scope', '$sce', '$uibModal', 'Game', 'GameFormat', 'PlayfieldType', 'Persona',
($scope, $sce, $uibModal, Game, GameFormat, PlayfieldType, Persona) ->
$scope.step = 1
###This works...when it is not an Array
$scope.html = "On which Playfield is the " + "<strong>Standard</strong>" + " game played ?"
$scope.stepQuestion = $sce.trustAsHtml($scope.html)
###How do I show the <strong> tags in my view when its an array?
$scope.stepQuestions = ['What should this Game be called?', 'What should this Game be called?',
'What category does this Game belong to?',
'On which Playfield is the <strong>Standard</strong> game played ?',
'What is the Player Configuration?', 'How is a <strong>Standard</strong> game won?', 'Which Persona owns this Game?']
]
$scope.stepQuestions = $scope.stepQuestions.map (item) -> $sce.trustAsHtml(item)
VIEWS
new.html.slim
form[name='gameCreateForm' ng-controller='GameCreateCtrl']
###This Works
.question ng-bind-html="stepQuestion"{{ stepQuestion }}
###This doesnt
.question ng-bind-html="stepQuestions"{{ stepQuestions[step - 1] }}
Please try: angularjs to output plain text instead of html (similar issue) or https://docs.angularjs.org/api/ng/directive/ngBindHtml
这篇关于应用&LT;强&GT;标签为一个字符串在我js.coffee文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!