使用 Flex 布局模块时如何向容器添加边距或填充?
模板:
<div class="container">
hell
<div fxLayout="column" fxLayoutAlign="center center">
<mat-card fxFill>Simple card test</mat-card>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
风格:
.container{
margin: 60px;
}
Run Code Online (Sandbox Code Playgroud)
我注意到它似乎没有添加正确数量的保证金。您将能够在屏幕截图中看到,flex 容器的边距小于其外部的文本。
假设我的应用程序结构如下所示:
|-- app
|-- components
|-- features
|-- models
|-- pipes
|-- services
|-- views
Run Code Online (Sandbox Code Playgroud)
现在我已经用一些方法创建了一个常规类,@Output
因此几个组件可以扩展这个类。我应该创建一个文件夹“类”吗?我从未在文档或文章中看到过这种情况。
以前我的应用程序正在使用Angular 4.4.6.我按照指南 https://angular-update-guide.firebaseapp.com/更新到Angular 5.我使用了这个:
npm install @angular/animations@'^5.0.0' @angular/common@'^5.0.0' @angular/compiler@'^5.0.0' @angular/compiler-cli@'^5.0.0' @angular/core@'^5.0.0' @angular/forms@'^5.0.0' @angular/http@'^5.0.0' @angular/platform-browser@'^5.0.0' @angular/platform-browser-dynamic@'^5.0.0' @angular/platform-server@'^5.0.0' @angular/router@'^5.0.0' typescript@2.4.2 rxjs@'^5.5.2'
Run Code Online (Sandbox Code Playgroud)
但它没有用.它会给我一个错误no valid target found for rxjs
.所以相反,我只是更改了我的package.json中的版本并运行npm install
并且它工作,但是当运行npm start时,我收到错误
WARNING in ./~/@angular/core/esm5/core.js
6456:15-102 Critical dependency: the request of a dependency is an expression
Run Code Online (Sandbox Code Playgroud)
所以我删除了我的node_modules并再次进行了npm安装,运行npm start时仍然遇到同样的错误.
我已经创建了一个简单的登录组件,我想垂直居中,但我不知道如何使用Angular Flex Layout库实现这一目标.
app.component.html
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
login.component.html
<div fxLayout fxLayoutAlign="center center">
<mat-card fxFlex="30%">
<mat-card-title>Login</mat-card-title>
<mat-card-content fxLayout="column">
<mat-form-field>
<input matInput placeholder="Username">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Password">
</mat-form-field>
</mat-card-content>
<button mat-raised-button color="accent">Login</button>
</mat-card>
</div>
Run Code Online (Sandbox Code Playgroud)
styles.scss
body{
margin: 0;
background-color: #eff2f5;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Angularfire2。假设我有一个users
和comments
集合。添加评论时,引用创建评论的用户的正确方法是什么?起初我以为我可以简单地创建一个具有如下结构的评论:
{
message: string,
user: {
uid: string,
username: string,
...
}
}
Run Code Online (Sandbox Code Playgroud)
但问题是,如果用户更新他的个人资料,那么这里的数据就会不正确。是否可以在创建评论时简单地提供用户的 id,并在查询评论时获取整个用户的数据?
假设我有一个这样的表格:
this.form = fb.group({
genders: [['MALE']],
});
Run Code Online (Sandbox Code Playgroud)
我已经实现了自己的自定义表单控件,该控件实现了 ControlValueAccessor 接口。我知道我们有该writeValue
方法,但只有在使用 或 时才会调用该setValue
方法patchValue
。如何获取 的FormBuilder
方法中设置的默认值group
?