How to remove "property binding not used by any directive" error in Dart Angular2 tutorial?


I am doing this tutorial:

Now, I am trying to get list of heroes on the page. There is error while compiling template from tutorial. This is template: I am getting this error:

Build error:
Transform TemplateCompiler on ng2_hero_app|lib/app_component.ng_meta.json threw error: Template parse errors:
Property binding ngForOf not used by any directive on an embedded template ("
      <h2>My Heroes</h2>
      <ul class="heroes">
        [ERROR ->]<li *ngFor="let hero of heroes"
          [class.selected]="hero == selectedHero"
          (click)"): AppComponent@3:8
Property binding ngIf not used by any directive on an embedded template ("

What I tried?

  • I tried it by myself first, got error. I copy-pasted code from github then and I am getting same error.
  • I tried to re-run pub get (I thought there is some error like missing some npm package when developing node module).
  • I tried to research and found this. This post says, that I should rewrite code of *ngFor directive. Well, I tried, templated compiled successfully, but I got nothing on page.

This is my current app_component.dart code:


You might miss COMMON_DIRECTIVES in pubspec.yaml

  - angular2/transform/codegen:
      platform_directives: 'package:angular2/src/common/directives.dart#CORE_DIRECTIVES'

This is RC syntax which is not yet available for Dart

<li *ngFor="let hero of heroes"

in beta it is

<li *ngFor="#hero of heroes"

See also and the linked wiki document where PLATFORM_PIPES are mentioned which can be made available globally this way as well.

Answered By – Günter Zöchbauer

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.