Mat*_*s.h 2 angular-material angular
嘿,我是Angular的新手,我想从matsnackbar获取数据.
可能吗 ?
apiName: string;
this.snackBar.openFromComponent(CustomSnackbarComponent, {
duration: 5000000,
data: this.apiName;
});
Run Code Online (Sandbox Code Playgroud)
我的组件:
export class CustomSnackBarComponent implements OnInit {
constructor(private sanitizer: DomSanitizer) { }
ngOnInit() {
}
}
Run Code Online (Sandbox Code Playgroud)
bug*_*ugs 12
你必须注入MAT_SNACK_BAR_DATA你的零食栏组件:
import {Component, Inject} from '@angular/core';
import {MAT_SNACK_BAR_DATA} from '@angular/material';
@Component({
selector: 'your-snack-bar',
template: '{{ data }}',
})
export class CustomSnackBarComponent {
constructor(@Inject(MAT_SNACK_BAR_DATA) public data: any) { }
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1408 次 |
| 最近记录: |