If you want to achieve this functionality, simply insert the following code inside the function within the demo controller:
$scope.arr = [];
for(let x of [{name:"1st Item",taste:"sweet"},{name:"2nd item",taste:"spicy"}]) {
let newArr = [];
newArr.push(x.name);
newArr.push(function ($itemScope) {
alert($itemScope.item.cost);
});
$scope.arr.push(newArr);
}
Next, replace the existing array of "Alert Cost" and "Alert Player Gold" with $scope.arr.
$scope.menuOptions = [
['Buy', function ($itemScope) {
$scope.player.gold -= $itemScope.item.cost;
}],
null,
['Sell', function ($itemScope) {
$scope.player.gold += $itemScope.item.cost;
}, function ($itemScope) {
return $itemScope.item.name.match(/Iron/) == null;
}],
null,
['More...', $scope.arr]
];
Once that's done, you're all set to go. Feel free to check out this live example on CodePen: Working example