Angular Add & Get Custom Attribute Value

Today, We want to share with you Angular Add & Get Custom Attribute Value.In this post we will show you angular add attributes to element, hear for how to get data by id in angular 7 we will give you demo and example for implement.In this post, we will learn about Get Custom Attributes Value in Angular? with an example.

Angular Add & Get Custom Attribute Value

There are the Following The simple About angular 6 get element by id Full Information With Example and source code.

As I will cover this Post with live Working example to develop attributes binding in angular 7, so the how to get data by id in angular 4 is used for this example is following below.

How to Add & Get Custom Attribute Value in Angular?

src/app/app.component.ts

import { Component } from '@angular/core';
  
@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  name = 'Angular';
    
  websites = [
    {id:1, name:"pakainfo"},
    {id:2, name:"ministackoverflow"},
    {id:3, name:"infinityknow"},
  ]
  
  clickEvent(e){
    var id = e.getAttribute('data-id');
    console.log(id);
  }
}

src/app/app.component.html

angular add and get custom attribute to element - Pakainfo.com

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about how to get data by id in angular 4.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment