小编pet*_*len的帖子

AngularJS - 将单选按钮绑定到具有布尔值的模型

我在将单选按钮绑定到属性具有布尔值的对象时遇到问题.我正在尝试显示从$资源中检索到的考试题目.

HTML:

<label data-ng-repeat="choice in question.choices">
  <input type="radio" name="response" data-ng-model="choice.isUserAnswer" value="true" />
  {{choice.text}}
</label>
Run Code Online (Sandbox Code Playgroud)

JS:

$scope.question = {
    questionText: "This is a test question.",
    choices: [{
            id: 1,
            text: "Choice 1",
            isUserAnswer: false
        }, {
            id: 2,
            text: "Choice 2",
            isUserAnswer: true
        }, {
            id: 3,
            text: "Choice 3",
            isUserAnswer: false
        }]
};   
Run Code Online (Sandbox Code Playgroud)

使用此示例对象,"isUserAnswer:true"属性不会导致选择单选按钮.如果我将布尔值封装在引号中,它就可以工作.

JS:

$scope.question = {
    questionText: "This is a test question.",
    choices: [{
            id: 1,
            text: "Choice 1",
            isUserAnswer: "false"
        }, {
            id: 2,
            text: "Choice 2", …
Run Code Online (Sandbox Code Playgroud)

data-binding model radio angularjs

196
推荐指数
4
解决办法
21万
查看次数

用HTML连接flash消息?

我想在connect-flash消息的文本中包含一个链接:

JS

req.flash("registerMessage", "Sorry, the User ID you chose is already in use. Please choose another. If you have already registered and need assistance logging in, <a href=\"http://www.example.com/support/\">contact support</a>");
Run Code Online (Sandbox Code Playgroud)

EJS

<% if (message.length > 0) { %>
  <div class="alert alert-danger"><%= message %></div>
<% } %>
Run Code Online (Sandbox Code Playgroud)

结果

<div class="alert alert-danger">Sorry, the User ID you chose is already in use. Please choose another. If you have already registered and need assistance logging in, &lt;a href=&quot;http://www.example.com/support/&quot;&gt;contact support&lt;/a&gt;.</div>
Run Code Online (Sandbox Code Playgroud)

有没有办法阻止Flash转义HTML字符,以便我可以在我的消息中显示链接?

ejs node.js express connect-flash

3
推荐指数
1
解决办法
2834
查看次数

标签 统计

angularjs ×1

connect-flash ×1

data-binding ×1

ejs ×1

express ×1

model ×1

node.js ×1

radio ×1