# Dynamic Inject html file

**URL:** <https://discourse.aurelia.io/t/dynamic-inject-html-file/1374>\
**Category:** Help Requests\
**Created:** [June 28, 2018, 1:14pm UTC](https://discourse.aurelia.io/t/dynamic-inject-html-file/1374 "2018-06-28T13:14:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fasadin](https://avatars.discourse-cdn.com/v4/letter/f/b5ac83/32.png) [@fasadin](https://discourse.aurelia.io/u/fasadin)\
**Post date:** [June 28, 2018, 1:14pm UTC](https://discourse.aurelia.io/t/dynamic-inject-html-file/1374/1 "2018-06-28T13:14:03Z")

</div>

Hello everyone 🙂

I am quite new in Frontend development, so please don’t be super harsh 🙂

Problem:  
Based on value in drop-down list I have to show on the same screen different form (completely different contracts). I have two ideas how to solve this but first how looks dropdown list

```auto
public providers = ['None' , 'Something', 'Anything']

```

```auto
<select class="form-control" value.two-way="activeSigningProvider">
    <option repeat.for = "provider of providers">${provider}</option>
</select>

```

1. I can write two forms in one html and based on flags enable correct ones

```auto
<input disabled.bind="activeSigningProvider !== 'Anything'" class="form-control" type="text" />

```

1. I can have four HTMLs . One is “container” for all three states. Based on value I inject correct HTML using Key/Value collection

I know how to do 1) solution, but I don’t like it. It’s contains magic strings and it’s not nice if I want to expand it with another value. Code will quickly grow messy. So I wanted to do 2nd approach but I have no idea how. I tried googling it… but I think I am using wrong name

Maybe there is even better solution that I cannot came up with 🙂

---

<div class="post-metadata">

**Author:** ![fasadin](https://avatars.discourse-cdn.com/v4/letter/f/b5ac83/32.png) [@fasadin](https://discourse.aurelia.io/u/fasadin)\
**Post date:** [June 29, 2018, 9:13am UTC](https://discourse.aurelia.io/t/dynamic-inject-html-file/1374/2 "2018-06-29T09:13:28Z")

</div>

Of course it was typical problem XY so now I know there are compontents so I can do

```auto
<here-nice-form if.bind="activeSigningProvider === 'Something'" view-model.ref="HereNiceForm"></here-nice-form>

```

---

<div class="post-metadata">

**Author:** ![Malexion](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/malexion/32/188_2.png) [@Malexion](https://discourse.aurelia.io/u/Malexion)\
**Post date:** [June 29, 2018, 1:29pm UTC](https://discourse.aurelia.io/t/dynamic-inject-html-file/1374/3 "2018-06-29T13:29:30Z")

</div>

Probably a bit late but it sorta sounds like you could have used compose to dynamically shift the forms into a space, it’s like dynamically loading a component but you don’t have to worry about global resources.

```auto
<div if.bind="formName">
   <compose view-model="app/forms/${formName}"></compose>
</div>

```
