简体   繁体   中英

How to append innerHTML of a button on Ember.view

I have created a view for button.

App.NumberButtonView = Ember.View.extend({
tagName: 'button',
classNames: ['ButtonClass']
});

My button model is

App.NumberBtns = DS.Model.extend({
value: DS.attr('string'),
width: DS.attr('string'),
height: DS.attr('string'),
className: DS.attr('string'),
type:DS.attr('string')

})

App.NumberBtns.FIXTURES = [  {
id: '108',
value: '8',
style: {
    width: '50px',
    height: '50px'
},
className: 'NumberBtnClass',
type: 'number',
}, {
id: '109',
value: '9',
style: {
    width: '50px',
    height: '50px'
},
className: 'NumberBtnClass',
type: 'number',
}, {
id: '110',
value: '0',
style: {
    width: '50px',
    height: '50px'
},
className: 'NumberBtnClass',
type: 'number',

} ]

How can i pass the value of the button to the view from the controller.

We can do it by adding tags and appending the innerHTML. But how to append the innerHTML in the buttonView from model through controller

We can set the controller using

setupController: function (controller, model) {
    controller.set('model', model);

to display the name use itemBinding

{{#each btn in model.operatorBtn}}
{{#view App.NumberButtonView itemBinding="btn"}}
<i> {{view.item.value}} </i>
{{/view}}
 {{/view}}
 {{/each}

Now the value will get displayed in the view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM