0

I'm trying to get a form with the field Exchange already populated as "HELLO". Using value in HTML is not working and the field is showing up blank.

I tried adding autocomplete=off, but that did not work either.

<div class="form-group">

    <label for="AccountRef">Account Ref</label>
        <div class="input-group">
                <input type="text" id="accountref" name="accountref" [(ngModel)]="newAccount.accountRef">
                <div class="input-group-append"></div>
              </div>

    <label for="Client">Client Name</label>
        <div class="input-group">
            <input type="text" id="client" name="client" [(ngModel)]="newAccount.client">
            <div class="input-group-append"></div>
        </div>

    <label for="Exchange">Exchange</label>
        <div class="input-group">
            <input type="text" id="exchange" name="exchange" value ="HELLO" autocomplete="off" [(ngModel)]="newAccount.exchange">
            <div class="input-group-append"></div>
        </div>

</div>
2
  • As far as I see, you have additional 'space' after 'value'. Have you tried different browsers? What webkit are you testing on? (M.) Commented Apr 22, 2019 at 18:45
  • I just tried it with plain HTML (deleted the angular [(ngModel)]=...) and it worked fine. So it's likely something to do with that, if that narrows down your problem at all. Commented Apr 22, 2019 at 18:46

3 Answers 3

1

since you are using two way binding [(ngModel)]=newAccount.exchange you need to populate value using newAccout.exchange

So in your ts/js file give default value Try this:newAccout.exchange="Hello"

Sign up to request clarification or add additional context in comments.

Comments

0

It's working for me. Try another browser or better another IDE -Sublime, Webstorm, Visual Code etc.

Comments

0

As @Ashok said you need to populate 'newAccount.exchange' but if you want to just populate the value html without [(ngModel)] you need 1 way data binding.

<input type="text" id="exchange" name="exchange" [value]="newAccount.exchange" autocomplete="off">

Comments

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.