mdbootstrap / mdb4-angular-ui-kit

Angular Bootstrap with Material Design - Powerful and free UI KIT
https://mdbootstrap.com/docs/angular/
MIT License
18 stars 1 forks source link

Input Field with Label has no border #1

Closed domhel closed 3 years ago

domhel commented 3 years ago

I have the following html-code:

<div class="d-flex">
    <input type="number" id="myInput" class="form-control"">
    <label for="myInput" class="form-label">Input Label</label>
</div>

Without a label, there is a border but with label the border disappears. I have read that I need to insert this code:

document.querySelectorAll('.form-outline').forEach((formOutline) => {
    new mdb.Input(formOutline).init();
})

But this is not the angular way of coding and mdb.Input doesn't even exist.

So how can I initialize a mdb Input with Angular?

idzark commented 3 years ago

Here is an example of Angular syntax:

<mdb-form-control>
  <input mdbInput type="text" id="form1" class="form-control" />
  <label mdbLabel class="form-label" for="form1">Example label</label>
</mdb-form-control>

The component will be initialized automatically when you use this code.

domhel commented 3 years ago

Thanks, it works. I didn't know that I have to use tags like and <input mdbInput ...> In the mdb angular docs it looks like you only need the bootstrap classes and no material design specific tags/directives.