Welcome to my app!
Here is some content...
'Angular Dart Portals”翻译为'Angular Dart门户”,它是一种将子组件传输到DOM树中不同部分的技术。使用Angular Dart门户,您可以在各种应用程序中构建强大的用户界面。
下面是一个简单的Angular Dart门户示例,该示例将应用程序的内容部分传输到侧边栏中:
import 'package:angular/angular.dart';
import 'package:angular_components/angular_components.dart';
@Component(
selector: 'my-app',
template: '''
Welcome to my app!
Here is some content...
''',
directives: [
MaterialButtonComponent,
PortalDirective,
],
)
class AppComponent {}
在模板中,我们创建了一个名为sidebar
的门户模板,并在侧边栏中嵌入了一些HTML内容。我们使用PortalDirective
指令将这个门户放入模板中运行。
要在组件中实现该门户,我们引用PortalHostDirective
并在将门户放入DOM之前等待渲染。我们还需要使用PortalHostDirective
指令,在模板中来放置并呈现门户。下面是一个在组件中的示例:
import 'dart:async';
import 'package:angular/angular.dart';
import 'package:angular_components/angular_components.dart';
@Component(
selector: 'my-app',
template: '''
Welcome to my app!
Here is some content...
''',
directives
上一篇:AngularDart模板中能使用枚举吗?如果可以,如何使用?
下一篇:AngularDart是什么?它与Angular 2+有什么不同?为什么没有人谈论它?它是好还是坏? 请问AngularDart是什么?与Angular 2+有何区别?为何无人讨论?它是好还是不好?