簡體   English   中英

將模型傳遞給Bootstrap用於Ember Popovers

[英]Passing models to Bootstrap for Ember Popovers

對任何使用Bootstrap for Ember組件的人都可以幫助找出一些東西。

使用{{bs-bind-popover}}時如何將模型傳遞給組件

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

在控制器中我使用了示例中的代碼:

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 model}}之類的東西

您可以將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'),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM