0

我坚持执行该指令。尝试通过自定义指令向按钮添加“mat-raised-button”和“color”。但它没有用。请帮我解决这个问题。代码在这里,

import { Directive, ElementRef, Renderer2, HostListener, AfterViewInit } from '@angular/core';
import { MatRipple } from '@angular/material';
import { MatRipple } from '@angular/material';
@Directive({
    selector: '[appButton]',
    providers: [MatRipple]
})
export class ButtonDirective{
    constructor(el: ElementRef, renderer: Renderer2, ripple: MatRipple) {
        renderer.setAttribute(el.nativeElement, 'mat-raised-button', '');
        renderer.setAttribute(el.nativeElement, 'color', 'primary');
    }

}
4

0 回答 0