Add class to ember link-to

后端 未结 3 1892
伪装坚强ぢ
伪装坚强ぢ 2021-02-01 12:46

I try to build a link to a nested route and want to add a class to this link (for twitter bootstrap)

The result should something like this:

< a href=\         


        
相关标签:
3条回答
  • 2021-02-01 13:03

    Use:

    {{#link-to 'rent' rent class='btn btn-primary btn-small'}}Go to rent{{/link-to}}

    As link-to is a view helper.

    0 讨论(0)
  • 2021-02-01 13:21

    You can add classes just fine in {{#linkTo}} helpers, you just need to remember not to confuse ember.

    Ember may think your class is the routeName of the params, I include the class after both params and routeName and it works fine.

    {{#linkTo 'dashboard.screenshots' value.model class='thumbnail'}}
       ........
    {{/linkTo}}
    

    Produces

    <a id="ember507" class="ember-view thumbnail" href="#/project-2/member-1/task-2/screenshot-30">
       .........
    </a>
    
    0 讨论(0)
  • 2021-02-01 13:23

    If you want manually construct something from variables - there is {{unbound}} helper in ember.js.

    In yor case code will looks like:

    <a href="/#/rents/{{unbound rend.id}}" class="btn btn-primary btn-small">
       do something
    </a>
    
    0 讨论(0)
提交回复
热议问题