javascript - 将模型传递给 Bootstrap for Ember Popovers

标签 javascript twitter-bootstrap ember.js

致所有使用 Bootstrap for Ember 的人组件,可以帮助找出一些东西。

如何在使用{{bs-bind-popover}时将模型传递给组件

<div {{bs-bind-popover templPop}}>Show popover</div>

在 Controller 中,我使用了示例中的代码:

templPop: Ember.Object.create({
  firstName: 'numbers',
  title: 'Popover with Template',
  template: 'numbers:<ul>' +
          '{{#each val in content.numbers}}' +
          '   <li>{{val}}</li>' + '{{/each}}' +
          '</ul>',
  content: {
    numbers: [1, 2, 3]
  }

})

将模型或其他参数传递给 bs-bind-popover 以便我可以在 templPop 内容和模板中使用它们的方法是什么?

类似于{{bs-bind-popover templPop 模型}}

最佳答案

您可以将 templPop 属性转换为计算属性:

 templPop:function(){

     return Ember.Object.create({

      firstName: 'numbers',
      title: 'Popover with Template',
      template: 'numbers:<ul>' +
              '{{#each item in content.model}}' +
              '   <li>{{model.property}}</li>' + '{{/each}}' +
              '</ul>',
      content: {
        model: this.get('model')
        }
     });
 }.property('model'),

关于javascript - 将模型传递给 Bootstrap for Ember Popovers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24272685/

相关文章:

javascript - ng-table 通过选择下拉菜单过滤

jquery - 同位素/砌体类型插件,适用于 Bootstrap 3 和不同的网格宽度

HTML CSS : Make Parent Flex equal Width of Children Automatically

html - DIV间距的困难

ember.js - Ember-Cli:在 findAll() 查询前添加前缀

javascript - ember.js 包括自定义 js

javascript - 如何向 EmberJS 输入助手添加条件

javascript - 在 Javascript 的构造函数中访问不是使用 'this' 关键字创建的变量

php - 在某些版本的 Chrome 中无法使用 Javascript 更改图像的 src

javascript - 遍历 Mongoose 查找结果