作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在单击“应用布局”的component-a
内的component-b
项时,从component-c
和material-navigation
替换material-content
。
app_layout_component.dart
import 'package:angular/angular.dart';
import 'package:angular_components/app_layout/material_persistent_drawer.dart';
import 'package:angular_components/content/deferred_content.dart';
import 'package:angular_components/material_button/material_button.dart';
import 'package:angular_components/material_icon/material_icon.dart';
import 'package:angular_components/material_list/material_list.dart';
import 'package:angular_components/material_list/material_list_item.dart';
import 'package:angular_components/material_toggle/material_toggle.dart';
@Component(
selector: 'app-layout',
directives: const [
DeferredContentDirective,
MaterialButtonComponent,
MaterialIconComponent,
MaterialListComponent,
MaterialListItemComponent,
MaterialPersistentDrawerDirective,
MaterialToggleComponent,
],
templateUrl: 'app_layout_component.html',
styleUrls: const [
'app_layout_component.css',
'package:angular_components/app_layout/layout.scss.css',
])
class AppLayoutComponent {
bool end = false;
}
<material-drawer persistent #drawer="drawer" [attr.end]="end ? '' : null">
<material-list *deferredContent>
<div group class="mat-drawer-spacer"></div>
<div group>
<material-list-item>
<material-icon icon="inbox"></material-icon>Inbox
</material-list-item>
<material-list-item>
<material-icon icon="star"></material-icon>Star
</material-list-item>
<material-list-item>
<material-icon icon="send"></material-icon>Sent Mail
</material-list-item>
<material-list-item>
<material-icon icon="drafts"></material-icon>Drafts
</material-list-item>
</div>
<div group>
<div label>Tags</div>
<material-list-item>
<material-icon icon="star"></material-icon>Favorites
</material-list-item>
</div>
</material-list>
</material-drawer>
<material-content>
<header class="material-header shadow">
<div class="material-header-row">
<material-button icon
class="material-drawer-button" (trigger)="drawer.toggle()">
<material-icon icon="menu"></material-icon>
</material-button>
<span class="material-header-title">Simple Layout</span>
<div class="material-spacer"></div>
<nav class="material-navigation">
<a href="#AppLayout">Link 1</a>
</nav>
<nav class="material-navigation">
<a href="#AppLayout">Link 2</a>
</nav>
<nav class="material-navigation">
<a href="#AppLayout">Link 3</a>
</nav>
</div>
</header>
<component-a></component-a>
</material-content>
最佳答案
您有多种选择:
NgIf
来控制基于某些条件显示的窗口小部件-如果您有两个或三个标准窗口小部件关于angular - AngularDart-如何在AppLayout中替换组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49176335/
我是一名优秀的程序员,十分优秀!