I'm struggling to comprehend how to insert an array into an object property. I've tried several approaches but I still can't seem to grasp it. What I'm aiming to achieve is to add a menu item to my menu and then include subitems. You can find the codepen link below. CodePen
var app = angular.module('app', []);
app.controller('appController', ['$scope', function($scope) {
$scope.pushChildren = function(child){
$scope.menu[menu.length - 1].children.push({link:child,title:child})
};
$scope.pushMenu = function(link, title){
$scope.menu.push({link:link,title:title,children:[]})
};
$scope.menu = [
// rest of the code...
];
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container" ng-app="app" data-ng-controller="appController">
<div class="row">
<nav class="col-md-2">
<ul class="custom-menu nav nav-pills nav-stacked span2">
// rest of the code...
</div>
</div>
</div>