I am trying to learn TypeScript and Angular. I have an object that I would like to loop through and pull key:value pairs so I can create buttons dynamically in HTML. In HTML when I <<variable>> my object I get "[object Object]" as my output. When I do standard ng-repeat="o in variable" I get nothing.
My question is how do I loop through it so I can get values stored in that object.
HTML
<div id="main_menu" class="container" role="main">
<div class="container-fluid">
<div class="row">
<div class="page-header">WebJB</div>
<div class="col-md-6">
<div class="panel panel-default">
<button href="#" class="panel-body btn btn-primary form-control">
<h3 class="panel-title"></h3>
</button>
</div>
<div ng-repeat="o in menu_parts"> <<--- I TRIED THIS
{{menu_parts}}
</div>
</div>
</div>
</div>
</div>
TypeScript
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-index',
templateUrl: './index.component.html',
styleUrls: ['./index.component.css']
})
export class IndexComponent implements OnInit {
menu_parts = {
"CRM": {
"name": "CRM",
"link": "/",
"colour": "white",
"label": "CRM"
},
"Admin": {
"name": "Admin",
"link": "/admin",
"colour": "red",
"label": "Admin"
},
"Dashboard": {
"name": "Dashboard",
"link": "/dashboard",
"colour": "white",
"label": "Dashboard"
},
"Settings": {
"name": "Settings",
"link": "/settings",
"colour": "white",
"label": "Settings"
}
}
constructor(){
var x = this.menu_parts;
console.log(x);
}
ngOnInit() {
}
}