垫扩展面板在按Enter时关闭

时间:2019-02-27 02:16:58

标签: angular angular-material

我有一个垫子扩展面板,

https://stackblitz.com/edit/angular-6kpdhy?file=app/expansion-overview-example.html

我想禁用“按回车时切换”功能,所以我尝试添加

#include <stdio.h>
#include <conio.h>
#include <math.h>

int main()
{
    int decider;
    double radius, height, circumference, surfaceArea, volume;
    const double PI = 3.14159265;

    printf("please enter radius in cm:");
    scanf("%lf", &radius);
    printf("please enter height in cm:");
    scanf("%lf", &height);
    printf("C. Calculate and display the circumference of the base of the cone\n"
           "S. Calculate and display the surface area of the cone\n"
           "V. Calculate and display the volume of the cone\n");
    scanf("%d", &decider);
    switch(decider)
    {
        case 'c':
        case 'C':
            circumference = (2.0f*PI)*radius;
            printf("%lf cm", circumference);
            break;
        case 's':
        case 'S':
            surfaceArea = PI * (pow(radius, 2)) + (PI * radius) * (sqrt((pow(height, 2)) + (pow(radius, 2))));
            printf("%lf cm sqaured", surfaceArea);
            break;
        case 'v':
        case 'V':
            volume = PI * (pow(radius, 2)) * (height/3.0f);
            printf("%lf cm cubed", volume);
            break;
        default:
            printf("An invalid option was selected!");
    }

    getch();
    return 0;
}

(keyup.enter)="$event.stopPropagation();"

但是它不起作用。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情吗?

<mat-expansion-panel #matExpansionPanel (keyup.enter)="keyEnter(matExpansionPanel,$event)">

Ts代码:

keyEnter(matExpansionPanel: MatExpansionPanel) {
      matExpansionPanel.close(); 
}