4

This is the Angular2 template:

<paper-dropdown-menu label="Country">
        <paper-listbox class="dropdown-content" [(ngModel)]="selectedCountry" (ngModelChange)="GetAdmin1s($event)">
            <paper-item *ngFor="let country of countries" value="{{country.Id}}">{{country.Name}}</paper-item>
        </paper-listbox>
    </paper-dropdown-menu>

I am getting this error:

"Template parse errors:
Property binding ngFor not used by any directive on an embedded template (""dropdown-content" [(ngModel)]="selectedCountry" (ngModelChange)="GetAdmin1s($event)">
            [ERROR ->]<paper-item *ngFor="let country of countries" value="{{country.Id}}">{{country.Name}}</paper-item>
 "): LocationComponent@4:12
Property binding ngForCountry not used by any directive on an embedded template (""dropdown-content" [(ngModel)]="selectedCountry" (ngModelChange)="GetAdmin1s($event)">
            [ERROR ->]<paper-item *ngFor="let country of countries" value="{{country.Id}}">{{country.Name}}</paper-item>
 "): LocationComponent@4:12"

Countries variable is defined as:

public countries: Array<Country> = [];

What is wrong with my use of ngFor? Why is it looking for ngForCountry?

3
  • You sure you're running angular2 >= beta-17? Commented May 14, 2016 at 3:32
  • Please post a plunkr, I'm unable to reproduce this (feel free to fork that one) Commented May 14, 2016 at 3:34
  • I just upgraded to rc.1 and I'm still getting an error. I'm trying to do the plunkr with all the dependencies involved. Commented May 14, 2016 at 6:15

2 Answers 2

1

Just try might help

  <paper-dropdown-menu label="Country">
    <paper-listbox class="dropdown-content" [(ngModel)]="selectedCountry" (ngModelChange)="GetAdmin1s($event)">
        <paper-item ngFor #country [ngForOf]="countries" value="{{country.Id}}">{{country.Name}}</paper-item>
    </paper-listbox>
  </paper-dropdown-menu>
Sign up to request clarification or add additional context in comments.

3 Comments

I think this worked. I'm getting an error in another part of the code instead. "No value accessor for '' in [selectedCountry in LocationComponent@3:48]"
@JonasArcangel for the value accessor error message see stackoverflow.com/questions/37202543/…
@mayur that's quite weird that this works. This ngFor syntax is supposed to only work on <template>. Very interesting find!
0

You can try : *ngFor="#country of countries"

1 Comment

I don't think this syntax is used anymore. I get "No provider for e! (e -> e)" error.

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.