0

I'm trying to dynamically create my template as below:

template: '<div> <input type="checkbox"  {{report-checkedvalue}} value="#:' + filterField + '#"/>#:' + filterField + '#</div>'

report-checkedvalue is my helper which returns checked or unchecked value for my checkbox input. But i can get it to work.I appreciate any help!

user5471528
  • 217
  • 2
  • 9
  • I think you should check out the input helper: https://guides.emberjs.com/v2.5.0/templates/input-helpers/#toc_checkboxes – t-sauer Jun 07 '16 at 13:06
  • You would need to compile the template and then inject it with the view layer. Don't do that. – Lux Jun 07 '16 at 13:26

2 Answers2

0

I don't know how things works in angularjs

But here is litle help i can

use conditional string for your template like

var isChecked = {{report-checkedvalue}} // true or false
var template = '';
if(isChecked){
    template = '<div> <input type="checkbox"  checked value="#:' + filterField + '#"/>#:' + filterField + '#</div>'
}
else {
    template = '<div> <input type="checkbox" value="#:' + filterField + '#"/>#:' + filterField + '#</div>'
}

That will generate checked and non-checked checkbox in your html.

Dee Nix
  • 170
  • 1
  • 13
0

If you want to dynamically compile your template on client side, I suggest you to read this answer: Dynamically compile a HTMLBars template at runtime in Ember 2.5 based on this one.

But this is far from an Ember convention and you probably should avoid if it is not absolutely necessary.

Community
  • 1
  • 1
bmeurant
  • 3,277
  • 1
  • 16
  • 14