Is it possible to extract attribute names of a DOM object using angular.element? If so, what is the process? If not, is there another way to access this information within Angular?

Is it possible to achieve this? If so, how can we accomplish it? Here is what I have attempted:

// Assuming domObj is a dom element
var ngObj = angular.element(domObj);
var attrNames = ngObj[0].attributes;

For example, let's consider the following dom element:

<div type="custom-type" name="dom-obj" class="dom-class" new-custom-attribute>
</div>

The desired outcome should be an array of strings:

["type", "name", "class", "new-custom-attribute"]

Answer №1

Absolutely, it is expected to run normally.

let jqueryObject = angular.element(nodeObject);
let attributeList = Array.from(jqueryObject[0].attributes).map(item => item.name)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angularjs - Repeatedly reloading identical images

Whenever I use ng-src in the <img> tag and change the ng-src by clicking next or previous buttons, the browser reloads the image even though it's already loaded. This results in a not-so-smooth experience as the image is downloaded again before ...

"Learn how to create a scrolling div using a combination of CSS and JavaScript with absolute and relative

After relying solely on "pre-made" components like Mui or TailWind, I decided to create a component using only CSS and maybe JavaScript. However, I encountered some difficulties when attempting to position a div inside an image using relative and absolute ...

AngularJS UI-Grid not displaying JSON data

Just started learning AngularJS and everything was going smoothly until I hit a roadblock... I have been struggling to display the JSON data returned from my REST service call. While hard-coding a data array in my controller works fine, displaying the act ...

html retrieve newly updated page from the provided link

I am facing an issue where I set a cookie on one page and try to unset it on the next page that I reach via a link. However, the cookie only gets unset when I refresh the second page by pressing F5. To test this scenario, I have added a link and some cook ...

How can I find a user's ID in a JSON file using for...in loop in Discord.js?

I'm facing an issue with this loop where I am only able to retrieve the guild id instead of the user id that I actually need. Here is my code: for(let userID in money){ res.push({"guildid": message.guild.id, "id": userID, " ...

Issue in Jhipster v2.20.0: Production mode causing static pictures to fail loading

I successfully launched a JHipster (v2.20.0) application in production mode. Within the AngularJS code, I have included the following line: img.src = assets/.../mypicture.png. When testing locally, the picture loads correctly. However, in production mode ...

I am receiving a Promise object with a status of "pending" within an asynchronous function on node.js

I have a nodejs class function that retrieves all rows from the database. module.exports = class fooClass { static async fooFunc() { const mysql = require('mysql'); const util = require('util'); const conn = mysql.createC ...

Extract the HTML table from Gmail and transfer it to Google Sheets with the help of Google Apps Script

Just dipping my toes into google apps script. On my to-do list is creating a script that can extract data from a table in Gmail and transfer it to Google Sheets. Here's an example of what the email body looks like: CONFIRMATION CODE GUEST&apo ...

How to disable sorting on the top LI element using jQuery?

I currently have two separate UL elements that are being sorted using the jQuery Sortable plugin. Each UL contains between one and ten LI elements arranged in a list format. $(".sortable").sortable({ connectWith: ".sortable", cancel: '.no-dra ...

Struggling with sending form data to the back end when uploading images in Angular

I've been facing a challenge trying to implement profile picture upload alongside standard text data and sending it all to the backend to create a new user through mongoose. Despite my efforts, using tools like ng-file-upload/angular-file-upload and e ...

Using Javascript to prevent css from changing the display

I want to make some CSS adjustments to a single element using a single script, but I want all the changes to be displayed at once. For example: $("#someelement").css({width:"100%"}); //this change should not be displayed $("#someelement").width($("#someel ...

Why is the radio button not chosen in the ns-popover popup? The radio button is only selected in the popup of the last column

In my Angular controller, I am trying to set the radio model but it is only appearing in the last column popup of the table. The ns-popover is displayed when clicking on a table column. Here is the Angular Code: var app = angular.module('app', ...

Obtain specific fields from a multidimensional array object using lodash

My dilemma involves working with an object that has the following structure: var data = [ { "inputDate":"2017-11-25T00:00:00.000Z", "billingCycle":6, "total":1 },{ "inputDate":"2017-11-28T00:00:00.000Z", "bi ...

Blazor combines the power of both C# and JavaScript by allowing them to be executed in a single

There is a button that triggers a JavaScript function: <button class="btn-orange btn" onclick="expand(this.closest('.profile'))">JavaScript</button> And there is another button that executes C# code and toggles ic ...

Generating a table with two columns utilizing ng-repeat

I am currently dealing with an array of objects that I need to showcase in a two-column layout. The challenge arises because some columns have more data than others, requiring equi-height rows. Despite utilizing Bootstrap and clearfix in my attempts to di ...

Guide on utilizing Vue to trigger an API call when the input box loses focus

I am currently facing challenges while trying to learn vue, and I am not sure how to proceed. I would greatly appreciate any assistance! To begin with, I want to acknowledge that my English may not be perfect, but I will do my best to explain my issue tho ...

Is there a way to prevent vertical scrolling during left swipes in Ionic?

I am in the process of creating an Ionic mobile application, where the main view consists of a vertical list of cards. I would like each card to be "swipable" in a similar fashion to Google Now cards. I have begun implementing this functionality: $scope. ...

Combine rows with the same value in the first column of an HTML table

My HTML table has dynamic content, and I need to merge rows in the first column only if their values are identical. You can see an image of the table here. Specifically, if the values in the first column match, those rows should be merged together while le ...

Navigating through the DOM using JavaScript or regular expressions

I have a DOM string called innerHTML and I am looking to extract or display the node value using either JavaScript's DOM API or JavaScript RegEx. "<nobr> <label class="datatable-header-sortable-child" onmousedown="javascript:giveFeedback(&ap ...

How can I send data in JSON format to a JavaScript AJAX request?

I've created a method that looks like this: public String getUTResult() throws IOException { BuildResultParser bp = new BuildResultParser(); BuildResultBean b = bp.getreadFile("C:\\bc.txt"); String str = b.getuTresult(); ...