我正在阅读 AngularDart路由教程 https://webdev.dartlang.org/angular/guide/router/1#libsrcroutesdart并发现了这个代码片段。
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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)