1

In one case a template will have

{{input/number value=record.VolM3}}

in another it will have

{{input/number value=record.VolBbl}}

Is there a way to make it such that the end part of the record attribute is accessed programmatically? i.e.

{{input/number value=record.Vol + volUnit}} or
{{input/number value=(concat record.Vol + volUnit)}} 

Is such a thing possible?

1
  • Hi @Mike R, does your volUnit defined in your controller or component?
    – Mikelemuel
    Oct 6, 2020 at 7:40

2 Answers 2

2

You can do it like so :

{{input type="number" value=(get record (concat "Vol" "M3"))}}
{{input type="number" value=(get record (concat "Vol" "Bbl"))}}

I tested it with dummy record.

record = {VolM3: "100", VolBbl: "101"}

Here i have created a gist with Working Example

1
  • 1
    while the actual way you get the value is 100% right it is important to notice that {{input type="number and {{input/number is not the same. The first is the ember internal input component and the second a component at components/input/number.hbs
    – Lux
    Oct 6, 2020 at 23:18
2

You can do

{{input/number value=(get record (concat "Vol" volUnit))}}

or in modern ember:

<Input::Number @value={{get record (concat "Vol" volUnit)}} />
2
  • If I got it right from the title of the question {{input/number}} is a helper not a component. So <Input::Number> would be wrong even in modern ember.
    – jelhan
    Oct 13, 2020 at 20:34
  • 1
    actually I wouldnt be so sure here. Historically {{input has been named a helper. Even in ember 3.0 the docs reference "The {{input}} helper", so I assume its just a confusion about the terms component and helper.
    – Lux
    Oct 14, 2020 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.