{"id":30598,"date":"2023-01-15T20:35:38","date_gmt":"2023-01-15T15:05:38","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/"},"modified":"2023-01-15T20:35:38","modified_gmt":"2023-01-15T15:05:38","slug":"solved-how-can-i-change-the-style-of-my-angularjs-object","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/","title":{"rendered":"[Solved] How Can i Change the style of my angularjs object?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-31394665\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"31394665\" data-parentid=\"31392858\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>Here&#8217;s a plunker(just JS) :<a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/plnkr.co\/edit\/h3EndN8F6milHF2h1gAj?p=preview\">http:\/\/plnkr.co\/edit\/h3EndN8F6milHF2h1gAj?p=preview<\/a> <\/p>\n<pre><code> var array =    [\n      {\n        9 : \"Alfreds Futterkiste\",\n        10 : \"Berlin\",\n        Room : \"201\"\n      },\n      {\n        9 : \"Vaffeljernet\",\n        10: \"\u00c5rhus\",\n        Room : \"204\"\n      }\n    ];\n\n  var result = {};\n\n  array.forEach(function(obj) {\n    \/\/function runs once for each element in the array, obj = element at current index\n    result[obj.Room] = {\n      9: obj[9],\n      10: obj[10]\n    };\n\n\n  });\n\n  console.log(result);\n<\/code><\/pre>\n<p>The basics are: [] is an array; {} is an object. In arrays things are identified by their index(0,1,2&#8230;). In objects they have keys. So <\/p>\n<pre><code>obj = {\"201\": {'key1':'value1', 'key2': 'value2'}}\n<\/code><\/pre>\n<p>means you have an object inside which you have another nested object (identified by it&#8217;s key &#8211; 201). The nested object has 2 properties. The first property has a key(key1)  and a value (value1)<\/p>\n<pre><code>obj[\"201\"] is {'key1':'value1', 'key2': 'value2'}\n<\/code><\/pre>\n<p>EDIT:<\/p>\n<p>I suppose you want a more general solution<\/p>\n<pre><code>     var newObj ={};\n     Object.keys(obj).forEach(function(key) {\n       if(key !== 'Room') {\n         newObj[key] = obj[key];\n       }\n     });\n     result[obj.Room] = newObj;\n<\/code><\/pre>\n<p>See if you can figure out where to put this<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">3<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How Can i Change the style of my angularjs object? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Here&#8217;s a plunker(just JS) :http:\/\/plnkr.co\/edit\/h3EndN8F6milHF2h1gAj?p=preview var array = [ { 9 : &#8220;Alfreds Futterkiste&#8221;, 10 : &#8220;Berlin&#8221;, Room : &#8220;201&#8221; }, { 9 : &#8220;Vaffeljernet&#8221;, 10: &#8220;\u00c5rhus&#8221;, Room : &#8220;204&#8221; } ]; var result = {}; array.forEach(function(obj) { \/\/function runs once for each element in the array, obj = element at current index result[obj.Room] &#8230; <a title=\"[Solved] How Can i Change the style of my angularjs object?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/\" aria-label=\"More on [Solved] How Can i Change the style of my angularjs object?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[930,333,356,430],"class_list":["post-30598","post","type-post","status-publish","format-standard","hentry","category-solved","tag-angularjs","tag-javascript","tag-json","tag-object"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How Can i Change the style of my angularjs object? - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How Can i Change the style of my angularjs object? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Here&#8217;s a plunker(just JS) :http:\/\/plnkr.co\/edit\/h3EndN8F6milHF2h1gAj?p=preview var array = [ { 9 : &quot;Alfreds Futterkiste&quot;, 10 : &quot;Berlin&quot;, Room : &quot;201&quot; }, { 9 : &quot;Vaffeljernet&quot;, 10: &quot;\u00c5rhus&quot;, Room : &quot;204&quot; } ]; var result = {}; array.forEach(function(obj) { \/\/function runs once for each element in the array, obj = element at current index result[obj.Room] ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-15T15:05:38+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How Can i Change the style of my angularjs object?\",\"datePublished\":\"2023-01-15T15:05:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/\"},\"wordCount\":118,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"angularjs\",\"javascript\",\"json\",\"object\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/\",\"name\":\"[Solved] How Can i Change the style of my angularjs object? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2023-01-15T15:05:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How Can i Change the style of my angularjs object?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How Can i Change the style of my angularjs object? - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How Can i Change the style of my angularjs object? - JassWeb","og_description":"[ad_1] Here&#8217;s a plunker(just JS) :http:\/\/plnkr.co\/edit\/h3EndN8F6milHF2h1gAj?p=preview var array = [ { 9 : \"Alfreds Futterkiste\", 10 : \"Berlin\", Room : \"201\" }, { 9 : \"Vaffeljernet\", 10: \"\u00c5rhus\", Room : \"204\" } ]; var result = {}; array.forEach(function(obj) { \/\/function runs once for each element in the array, obj = element at current index result[obj.Room] ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/","og_site_name":"JassWeb","article_published_time":"2023-01-15T15:05:38+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How Can i Change the style of my angularjs object?","datePublished":"2023-01-15T15:05:38+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/"},"wordCount":118,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["angularjs","javascript","json","object"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/","url":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/","name":"[Solved] How Can i Change the style of my angularjs object? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2023-01-15T15:05:38+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-change-the-style-of-my-angularjs-object\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How Can i Change the style of my angularjs object?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/30598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=30598"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/30598\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=30598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=30598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=30598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}