'Get the particular key and value in angular
I need help from this. how to get the particular key and value from the object.
{RuleExpression: 'DEFAULTS.epHDefaults.gen== true', Action: Array(0), DefaultActions: Array(3)}
Action: []
DefaultActions: (3) [{…}, {…}, {…}]
RuleExpression: "DEFAULTS.epHDefaults.gen== true"
[[Prototype]]: Object
here need RuleExpression(RuleExpression: "DEFAULTS.epHDefaults.gen== true") key value from the above in angular. Please help on this
Solution 1:[1]
This should help you:
const obj = { name: "My Property Name" };
for (const prop in obj) {
if (obj.hasOwnProperty(prop)) {
console.log(prop);
console.log(obj[prop]);
// do stuff
}
}
If you want to bind to a specific known property, just add the if clausule using the property name:
for (const prop in obj) {
if (obj.hasOwnProperty(prop) && prop === "name") {
console.log(prop);
console.log(obj[prop]);
// do stuff
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | viniciusmfelix |
