我只是在阅读 AngularDart routing tutorial并遇到了这个代码片段。
import 'package:angular/angular.dart';
import 'package:angular_router/angular_router.dart';
import 'route_paths.dart' as paths;
import 'crisis_list_component.template.dart' as clct;
import 'hero_list_component.template.dart' as hlct;
@Injectable()
class Routes {
static final _crises = new RouteDefinition(
routePath: paths.crises,
component: clct.CrisisListComponentNgFactory,
);
static final _heroes = new RouteDefinition(
routePath: paths.heroes,
component: hlct.HeroListComponentNgFactory,
); ..... see routing tutorial link above.
}
有什么作用
import 'crisis_list_component.template.dart' as clct;
import 'hero_list_component.template.dart' as hlct;
实际导入?
最佳答案
Angular 使用代码生成从 Angular 模板语法生成 Dart 代码。
这些组件导入生成的代码。
该代码包含路由器创建组件实例所需的工厂方法。
如果你有一个
import 'crisis_list_component.dart';
然后代码生成将生成一个额外的
import 'crisis_list_component.template.dart' as clct;
在这种情况下,它是用别名
clct
导入的
关于dart - AngularDart 中的 somecomponent.template.dart 导入指向什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50317847/