Dart implementation of Angular 2 directive ngFor generating error

Issue

The following compile time error is generated when trying to use the ngFor directive in the Dart implementation of Angular 2 Beta 0.

Property binding ngForOf not used by any directive on an embedded  template ("[ERROR ->]
<div *ngFor="#item of items">
{{item}}
</div>"):

Component:

library design;

import 'package:angular2/angular2.dart';

@Component(
    selector: 'design-component',
    templateUrl: 'design.html',
    viewProviders: const [CORE_DIRECTIVES]
)
class DesignComponent {
   List<String> items = ["One", "Two", "Three"];
}

Template:

<div *ngFor="#item of items">
   {{item}}
</div>

Any suggestions or help would be appreciated.

Solution

viewProviders should be directives. viewProviders are for dependency injection.

Answered By – Günter Zöchbauer

Answer Checked By – David Goodson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.