angular
I have a pretty basic scenario (somewhat new to angular). I am trying to convert JSON:
[
{\'name\': \'Nick\'},
{\'name\': \'David\'},
{\'name\':
You cannot do this. Instead, use a map
and join
. For example:
{{names}}
$scope.menuItems = [
{'name': 'Nick'},
{'name': 'David'},
{'name': 'John'},
];
$scope.$watch('menuItems', function(menuItems) {
$scope.names = menuItems.map(function(item) { return item.name }).join(',');
});
This will $watch
the menuItems
and update the names
property of the $scope
whenever menuItems
changes.