javascript - 我可以在 .json 对象中传递要与 css 一起使用的类吗?

标签 javascript css json angularjs

我有一个 .json 对象,然后由 ng-bind 通过 Angular 显示:

<p ng-bind-html="paragraph" ng-repeat="paragraph in content.sections[0].pages[1].paragraphs"></p>

.json 具有以下结构:

{
  "header":"A",
  "url":"#/us/en/a/b/c/c",
  "paragraphs":[
    "Something something <a class='plink' href='http://blahblah.com' target='_blank'>blah blah</a>."
  ]
}

代码已拉通,但类已删除。控制台中没有错误。

如何将类附加到该链接?

最佳答案

只需要使用带转义字符的双引号。

像这样:

{
  "header":"A",
  "url":"#/us/en/a/b/c/c",
  "paragraphs":[
    "Something something <a class=\"plink\" href='http://blahblah.com' target='_blank'>blah blah</a>."
  ]
}

关于javascript - 我可以在 .json 对象中传递要与 css 一起使用的类吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29566432/

相关文章:

javascript - 如何使用实用程序函数来检测操作系统和浏览器的 react ?

asp.net - 如何确保我的 href 优先于任何其他层,包括 flash?

html - 以子 div 为轴的圆形 div

python - 我可以用 Python 替换 JSON 键中的部分字符串吗?

facebook - Yii Facebook 注册

javascript - 使用纯 JS 无 CSS3 旋转 SVG

javascript - 优化 jQuery 代码

css - 文章的移动 View 不起作用

css - Bootstrap 按钮处于事件状态且目标样式不起作用

java - 无法使用 API v2 Foreman 1.7.1 创建主机