gpt4 book ai didi

javascript - 将 标签应用于我的 js.coffee 文件中的字符串

转载 作者:行者123 更新时间:2023-11-27 23:09:25 24 4
gpt4 key购买 nike

我目前正在我的 Ruby On Rails 项目中使用 Angular 和 Slim。我的 js.coffee 中有一系列问题,目前正在我的 View 中呈现。

数组中的一个字符串具有强标签,但它在我的 html 中没有正确显示。

我没有得到标准,而是得到了这个......

On which Playfield is the <strong>Standard</strong> game played ?

我对 Angular 还很陌生,我错过了什么?

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] }}

最佳答案

关于javascript - 将 <strong> 标签应用于我的 js.coffee 文件中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36299635/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com