0

私はどのように主要なテーマの色(角度材料)を取得するのか分かりません。 component.tsTypeScript/JavaScriptで角度材料のテーマカラーを使用するにはどうすればいいですか?

私はtemplate.htmlまたはmat-color($primary)style.scsscolor="primaryを使用できます。しかし、どのように私はキャンバス内の要素をスタイリングするためにテーマの色を使用するのですか? TypeScriptコードの中でどのように使用しますか?

情報:

"@angular/material": "^5.0.0-rc.2", 
"@angular/core": "^5.0.0" 

答えて

0

私はハックソリューションを使用。美しくはないが働いている。

component.html

<div #primary class="mat-button mat-primary" style="display:none"></div> 

component.ts

declare let getComputedStyle: any; 

export class Component implements AfterViewInit { 
    @ViewChild('primary') primary: ElementRef; 

    ngAfterViewInit() { 
     const primaryColor = getComputedStyle(this.primary.nativeElement).color; 
    } 
関連する問題