Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 5使用方法绑定属性?_Angular_Typescript - Fatal编程技术网

Angular 5使用方法绑定属性?

Angular 5使用方法绑定属性?,angular,typescript,Angular,Typescript,Angular和Typescript新手,尝试使用组件上的方法设置控件的属性。是否可以将按钮控件本身作为参数发送 <input type="button" id="Button1" data-something="{{ GetSomething(this) }}"> 如果您所说的this,指的是HTMLElement,则以下操作可能有效: 或阅读ngClass或类绑定: 如果您所说的这个,指的是HTMLElement,那么以下可能会起作用: 或阅读ngClass或类绑定:

Angular和Typescript新手,尝试使用组件上的方法设置控件的属性。是否可以将按钮控件本身作为参数发送

<input type="button" id="Button1" data-something="{{ GetSomething(this) }}">

如果您所说的
this
,指的是
HTMLElement
,则以下操作可能有效:

或阅读
ngClass
类绑定


如果您所说的
这个
,指的是
HTMLElement
,那么以下可能会起作用:

或阅读
ngClass
类绑定


您为什么要这样做?还有其他方法可以使用
*ngClass
[class.foo]
设置类,button元素不会真正告诉您任何事情。明白了,假设类是
数据-
属性。我在这个例子中使用了class。将进行编辑。为什么要这样做?还有其他方法可以使用
*ngClass
[class.foo]
设置类,button元素不会真正告诉您任何事情。明白了,假设类是
数据-
属性。我在这个例子中使用了class。将编辑。
GetSomething(sender) {

    //do something with sender being the Button

    console.log(sender.id);

    return "garbage";
}