我正在使用 angular2-dart 构建一个小型示例应用程序,但在设置路由时遇到错误:
异常:无法在路由器上找到反射信息
我的模板中有一个调用注销方法的按钮。单击时应用程序崩溃并出现错误。 这是我的代码:
import 'package:angular2/angular2.dart';
import 'package:angular2/router.dart';
@Component(
selector: 'home',
directives: const [CORE_DIRECTIVES],
templateUrl: 'home.html'
)
class Home {
Router router;
Home(Router _router) {
this.router = _router;
}
logout() {
this.router.parent.navigate(['/Login']);
}
}
我已阅读 this Angular 维基的一部分,但我不确定这与内置包有何关系。有什么指点吗?
最佳答案
向 @Component 添加 providers: const [ROUTER_PROVIDERS]
解决了这个问题。
关于dart - 在 Router 上找不到反射信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34382127/