0

The FormControlNames of my elements are generated dynamicly this way: id{{foo.foo_id}}{{bar.bar_id}}{{bob.bob_id}}

The result is something like id137.

When I now use {{form.controls.id137.status}}, in the HTML, I get VALID / INVALID like it should.

But when I do {{'form.controls.id' + foo.foo_id + bar.bar_id + bob.bob_id + '.status'}} I just get the line form.controls.id137.status on my page as a string, but it is not actually run.

How can I make Angular run this string?

2 Answers 2

1

try

{{ form.get('id'+foo.foo_id + '' + bar.bar_id + '' + bob.bob_id)?.status }}

or

{{ form.controls['id'+foo.foo_id + '' + bar.bar_id + '' + bob.bob_id]?.status }}
Sign up to request clarification or add additional context in comments.

Comments

1

You are creating a string when you add quotes around 'form.controls.id' and '.status'

Try something like:

{{ form.get('id' + foo.foo_id + bar.bar_id + bob.bob_id)?.status }}

2 Comments

@igor_c if ids are number, then your original code wasn't working, since you added some numbers, your edit is correct
yes, that's why I added 'id' to my id's. not working: id="137"; working: id="id137"

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.