如何修复 Dart 中的“getter isn't defined for class”错误?

How to fix 'getter isn't defined for class' error in Dart?

我的 Angular Dart 应用程序无法编译。我是 Angular Dart 的新手,我不明白问题出在哪里。

这是 BookListComponent:

import 'package:angular/angular.dart';

import '../book.dart';

@Component(
  selector: 'book-list',
  styleUrls: ['book_list_component.css'],
  templateUrl: 'book_list_component.html',
  directives: [NgFor],
)
class BookListComponent {
  List<Book> books = [
    new Book('Test 1'),
    new Book('Test 2'),
    new Book('Test 3')
  ];
}

这是 BookListComponent 模板:

<ul>
  <li ngFor="let book of books">{{ book.title }}</li>
</ul>

这是本书class

class Book {
  String title;

  Book(this.title);
}

编译时出现此错误:[error] The getter 'book' isn't defined for the class 'BookListComponent'. (package:bookshelf/src/book_list/book_list_component.template.dart)

模板错误,ngFor缺少主星。

<ul>
  <li *ngFor="let book of books">{{ book.title }}</li>
</ul>

同时将 Book class 更改如下。

class Book {
  String title;
  Book(String title) {
    this.title = title;  
  }
}