我对角度框架很陌生。我正在尝试在app.components.html文件中创建一个简单的按钮,单击该按钮后,我将看到一个在app.component.ts文件中声明的函数。当我使用(单击)事件属性时,一切正常工作,但当我使用onclick事件时,它不起作用。
app.component.html是一个HTML文件,那么为什么HTML鼠标事件不能在这里工作呢?谁来帮帮忙。app.component.html文件-
<input type="button" value="Click Me" onclick="getName('AAKASH')"/>app.component.ts文件-
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
// We can declare properties here
export class AppComponent {
title = 'blog';
getName(name) {
alert(
"button has been clicked" + name + " "
)
}
}发布于 2021-04-05 18:29:46
Html鼠标事件不以角形式出现。在角度上,html鼠标事件的名称与HTML不同。我们可以引用此链接来列出角-https://dev.to/orahul1/angular-mouse-events-41l9中的所有鼠标事件。
https://stackoverflow.com/questions/66957661
复制相似问题