Hi I'm a bit new to angular and trying to figure out how I could access a json key and iterate and print the values that are contained in an array. In my case below I'm trying to print the names along with their roles.
angular.module('employeeEarnestApp')
.controller('MainCtrl', function ($scope) {
$scope.employees = [ { id: 1, name: 'Alex', roles: ['admin','user','CEO'] },
{ id: 2, name: 'John', roles: ['developer','marketing'] },
{ id: 3, name: 'Kim', roles: ['sales','developer','CTO'] } ];
});
How could I use ng-repeat to print out the roles in the array? I'd imagine it might be something like this below?
<div class="container">
<h2>My Employees</h2>
<p class="form-group" ng-repeat="employee in employees">
{{employee.id}} - {{employee.name}}
<p class="form-group" ng-repeat="roles in {{employees.roles}}">
{{roles}}
</p>
</p>
</div>