将 <strong> 标签应用于我的 js.coffee 文件中的字符串

Apply <strong> tags to a string in my js.coffee file

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

数组中的一个字符串具有强标签,但在我的 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] }}

请尝试: angularjs to output plain text instead of html(类似问题) 或 https://docs.angularjs.org/api/ng/directive/ngBindHtml