应用<strong>标记到我的js.coffee文件中的字符串
Apply <strong> tags to a string in my js.coffee file
我目前在Ruby On Rails项目中使用Angular和Slim。我在js.coffee中有一系列问题,这些问题目前正在我的视图中呈现。
数组中的一个字符串具有强标记,但它没有在我的html中正确显示。
我得到的不是标准,而是。。。
On which Playfield is the <strong>Standard</strong> game played ?
我对棱角分明还很陌生,我缺少什么?
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)
视图
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] }}
请尝试:angularjs输出纯文本而不是html(类似问题)或https://docs.angularjs.org/api/ng/directive/ngBindHtml
相关文章:
- 可以't让我的if语句处理js中的html表单输入
- 使用agility.js进行页面布局和合成
- 可以't通过$getJSON上传参数使用js.coffee
- Rails中的共享JS(Coffee)
- 如何将HTML页面操作的范围限定为JS/Coffee文件中的唯一UserId
- 将coffee和js开发与Gulp相结合
- 应用<strong>标记到我的js.coffee文件中的字符串
- 如何使vim在编译.coffee时自动打开.js并保存回.js
- 带有foo.js和foo.js.coffee(空)的Rails资产管道导致js循环.为什么?
- 我如何将其转换为适合.js.coffee的jQuery格式
- 主干.js Model.get() 返回 undefined, 范围使用 coffeescript + coffee t
- 在javascript/js.coffee中访问json数据
- 使用js2coffe和bash将mass.js转换为.coffee
- 在Makefile任务期间复制.js并编译.coffee
- 用coffee文件编译js文件
- JS (Coffee-Script)在rails应用程序中不工作
- node.js, backbone, socketio, express和coffee script都在一起吗?
- 如何使用js/coffee来截屏asp页面
- Rails 4从.js.coffee视图调用CoffeeScript函数
- 如何在Coffescript .js.coffee中呈现ruby代码