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

标签 javascript ruby-on-rails angularjs ruby slim-lang

我目前正在我的 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/

相关文章:

javascript - 为 "single-page"webapp 禁用惯性滚动

javascript - CSS 动画导致 z-index 问题

javascript - 如何在 slack api 中没有 cron 作业的情况下安排诸如更改状态之类的操作

ruby-on-rails - 使用切换按钮代替复选框(Rails、Twitter Bootstrap、Simple_form)

ruby-on-rails - 无法使用 Rails 4 和 bootstrap-sass gem 在 Heroku 上使用 CSS

javascript - Angular 无法获取 javascript 屏幕键盘输入

javascript - react 绑定(bind)到复选框并根据选中更新状态

javascript - Ui-router、ng-repeat 和 ui state

angularjs - Angular Material 固定工具栏和粘页脚

java - 使用 Ruby 生成 Java 项目