对于mdDialog,我如何传入变量?具体来说,如何将Angular服务注入对话框组件?
我正在使用角度材料对话框2.
我想将数据传递给打开的组件.这是我点击按钮时打开对话框的方式
let dialogRef = this.dialog.open(DialogComponent, {
disableClose: true,
data :{'name':'Sunil'}
});
Run Code Online (Sandbox Code Playgroud)
在文档页面上有data属性,但是我在已安装的软件包中检查了MdDialogConfig
/**
* Configuration for opening a modal dialog with the MdDialog service.
*/
export declare class MdDialogConfig {
viewContainerRef?: ViewContainerRef;
/** The ARIA role of the dialog element. */
role?: DialogRole;
/** Whether the user can use escape or clicking outside to close a modal. */
disableClose?: boolean;
/** Width of the dialog. */
width?: string;
/** Height of the dialog. */
height?: string;
/** …Run Code Online (Sandbox Code Playgroud) 我有一个组件,用于Angular Material MdDialog:
@Component({
...
})
export class MyComponent {
constructor(@Inject(MD_DIALOG_DATA) public data: any, public dialogRef:
MdDialogRef<MyComponent>) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
我试图用Jasmine进行单元测试:
describe('MyComponent', () => {
let component: MyComponent;
let fixture: ComponentFixture<MyComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedTestingModule,
],
declarations: [
MyComponent,
],
})
.compileComponents();
}));
...
});
Run Code Online (Sandbox Code Playgroud)
不幸的是,我收到以下错误:
错误:没有InjectionToken MdDialogData的提供程序!
SharedTestingModule导入和导出我的自定义Angular Material模块,该模块本身导入并导出MdDialogModule.
我怎样才能摆脱这个错误?
非常感谢你!
Angular 4.2.4
Angular Material 2.0.0-beta.7
Jasmine 2.5.3
Run Code Online (Sandbox Code Playgroud) 只是想知道如何在Angular Material中更改默认字体...
默认是Roboto,我找不到将其更改为不同字体的方法.
我有这个,我会假设工作,但不是:
<mat-icon color="white">home</mat-icon>
Run Code Online (Sandbox Code Playgroud)
然后,我也有:
<button mat-raised-button color="accent" type="submit"
[disabled]="!recipientForm.form.valid">
<mat-icon color="white">save</mat-icon>SAVE
</button>
Run Code Online (Sandbox Code Playgroud)
此代码段由于某种原因确实有效(将图标显示为白色).
如何获得独行mat-icon以显示为白色使用的color属性?(我可以很容易地添加一个白班,但我想了解这一点)
我正在尝试在Angular Material中使用Datepicker组件.这是我的HTML代码:
<input matInput [matDatepicker]="picker" placeholder="Choose a date" disabled>
<mat-datepicker #picker disabled="false"></mat-datepicker>
Run Code Online (Sandbox Code Playgroud)
但是,它不适合我,我收到以下错误:
错误:MatDatepicker:找不到DateAdapter的提供程序.
错误消息告诉我,我需要导入MatNativeDateModule以及MatDatepickerModule,但我已经这样做了.这是我在app.module.ts下面的导入代码:
import {
MatFormFieldModule,
MatMenuModule,
MatCheckboxModule,
MatIconModule,
MatDatepickerModule,
MatNativeDateModule
} from '@angular/material';
Run Code Online (Sandbox Code Playgroud)
还有什么我想念的吗?
我想将角度材料添加到我的 nx 工作空间中。
角度材料文档(https://material.angular.io/guide/getting-started)说我应该运行ng add @angular/material。
我已经在我的 nx 工作区的根目录、我想要将其添加到的应用程序文件夹以及我想要将其添加到的 lib 项目文件夹中尝试过。在所有情况下我都会收到消息
The add command requires to be run in an Angular project, but a project definition could not be found.
Angular Material 文档曾经包含有关如何手动添加依赖项的说明,但我再也找不到了。现在有谁知道如何将其添加到 Nx 工作区中的项目中吗?
您有什么想法我如何翻译Angular mat-paginator标签中的"每页项目数" ?这mat-paginator是Material Design的一个元素.
angular-material ×10
angular ×8
angular7 ×1
angularjs ×1
jasmine ×1
javascript ×1
mddialog ×1
nrwl-nx ×1