小编and*_*ula的帖子

Angular 5和材质 - 如何从SnackBar组件更改背景颜色

我必须从快餐栏组件更改背景.我正在使用它来警告或通知用户有关用户所做的某些错误或已完成的操作.

项目的材料版本."@ angular/material":"^ 5.0.0-rc.1",

文档https://material.angular.io/components/snack-bar/api说一个改变类的api.

panelClass:string | string []要添加到小吃店容器的额外CSS类.

这是我在css文件中添加的内容.

.mycsssnackbartest {
  background-color: blue;
}
Run Code Online (Sandbox Code Playgroud)

这是打开小吃店的代码

this.snackBar.open('Informing the user about sth', 'User Message' , {
    panelClass: ['mycsssnackbartest ']
} );
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

angular-material2 angular

21
推荐指数
4
解决办法
2万
查看次数

角度5材料2 - 自动完成从外部api获取数据

我正在使用角5和材料2.

在ts文件中,我有这个专业:

      filteredOptions: Observable<any[]>;
Run Code Online (Sandbox Code Playgroud)

此属性将具有要在自动填充字段中显示的值数组.

      [{
        id:'1', name: 'teste 1'},
        {id:'2', name: 'teste 2'},
        {id:'3', name: 'teste 3'
      }]
Run Code Online (Sandbox Code Playgroud)

这个值数组来自数据库,它将在用户输入内容后显示.

html文件:

          ##            <form class="example-form">
          ##              <mat-form-field class="example-full-width">
          ##                <input type="text" placeholder="Assignee" aria-label="Assignee" matInput [formControl]="myControl" [matAutocomplete]="auto">
          ##                <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
          ##                  <mat-option *ngFor="let option of filteredOptions | async" [value]="option">
          ##                    {{ option.name }}
          ##                  </mat-option>
          ##                </mat-autocomplete>
          ##              </mat-form-field>
          ##            </form>
Run Code Online (Sandbox Code Playgroud)

ts文件示例:

    this.filteredOptions = Observable<any[]>;

    ngOnInit() {
      this.filteredOptions = this.myControl.valueChanges
        .pipe(
          startWith({}),
          map(getArrayOfValue(val))            
        );
      }

      // it is going to call …
Run Code Online (Sandbox Code Playgroud)

rest angular-material2 angular

11
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×2

angular-material2 ×2

rest ×1