错误:“hero”不是函数。(在[Angular_Dart_Tour_of_Heroes]lib\app_组件处调用_non_函数。dart:18)
英雄.dart
class Hero {
final int id;
String name;
Hero(this.id, this.name);
}
应用程序组件.dart
import 'package:angular/angular.dart';
import 'package:angular_components/angular_components.dart';
import 'hero.dart';
@Component(
selector: 'my-app',
styleUrls: const ['app_component.css'],
templateUrl: 'app_component.html',
directives: const [materialDirectives,],
providers: const [materialProviders],
)
class AppComponent {
final title = 'Tour of Heroes';
Hero hero = Hero(1, 'Windstorm');
}
应用程序组件.html
<h1>{{title}}</h1>
<h2>{{hero.name}}</h2>
<div><label>id: </label>{{hero.id}}</div>
<div><label>name: </label>{{hero.name}}</div>