4

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.

2 Answers 2

4

viewProviders should be directives. viewProviders are for dependency injection.

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

2 Comments

I am still getting the same error when trying to use the ng2_form_examples with Angular 2 Beta. Property binding ng-forOf not used by any directive on an embedded template (github.com/ng2-dart-samples/ng2_form_examples/blob/…)
Actually it works for me. I just missed that I had another ng-for in the template of my example application. After I changed that to ngFor as well all worked fine.
0

What worked for me was changing:

<li *ng-for="#name of friendNames">

To:

<li *ngFor="#name of friendNames">

In my template.

Here is my Component:

@Component(selector: "app",
           directives: const [NgFor],
           templateUrl: 'app_component.html')
class AppComponent{
    List<String> friendNames = const ["a", "b", "c"];
}

Gunther Zochbauer mentions this in comment to his answer.

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.