question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Placeholder not displayed when using ng-select with formGroupName (when the form is loaded)

See original GitHub issue

Expected behaviour

The placeholder should be dispalyed when the form is loaded

Actual behaviour

The input field is blanc (empty)

<form [formGroup]="form.group">
          <div class="form-group" formGroupName="adress">
            <label class="font-weight-bold"> Street</label>
            <ng-select placeholder="Select street" [items]="streets" formControlName="street"
              required bindLabel="label" bindValue="code">
            </ng-select>
          </div>
</form>

More Info

ng-select version: 2.1.3

browser: Chrome Version 67.0.3396.87

reproducible in demo page: No (It would be appreciated if added in the Demo page)

Thank you in advance.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

27reactions
varnastadeuscommented, Jul 2, 2018

Thanks, now I clearly see the issue. First param of FormControl is value, so changing new FormControl(null, Validators.required) works as expected.

7reactions
varnastadeuscommented, Jul 2, 2018

You don’t see label because your model is set with valid value, empty object is also valid. You should use null or undefined in your case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - placeholder not shown in ngselect - Stack Overflow
I found the solution finally, it's not in relation to the [multiple] attribute but the way to initialize my FormGroup, ...
Read more >
Resolved: ng-select placeholder not showing - truecodex.com
Fixed issue of placeholder not displayed when using ng-select in reactive form in Angular 6/7/8. Use null inseated of single quote ('') for ......
Read more >
How To Always Display A Placeholder Of Ngselect? - ADocLib
Placeholder not displayed when using ngselect with formGroupName when the form is loaded #653.Closed.yeddaalous opened this issue on Jul.
Read more >
FormGroupName - Angular
Accepts a name as a string or a number. The name in the form of a string is useful for individual forms, while...
Read more >
Ng Select Example (forked) - StackBlitz
<form [formGroup]="form". novalidate>. <h1>Angular ng-select <small ... ng-select">Open in Github</a></. small></h1> ... placeholder="Select City".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found