The problem is not due to the presence of a primitive value, but because of the presence of a property starting with $ , which indicates angular that this is its internal property (by convention) and you must skip it . Let's say if your key was something else that doesn't start with $ , it will work fine.
if you cannot format the object, then just get the keys of the object to the array and swipe through it.
Sort of:
<div ng-repeat="prop in getKeys(range)" ng-init="value=range[prop]"> {{prop}} = <div ng-repeat="key in getKeys(value)" ng-init="rangeValue=value[key]"> {{key}}: {{rangeValue}} </div> </div>
and
$scope.getKeys = function(obj) { return Object.keys(obj); }
(function() { var CHEAT = angular.module('cheat', []); CHEAT.controller('maps', function($scope) { $scope.search = ""; $scope.range = { "Globals": { "$": "M", "A": "Test", "M": { "z": "q" } }, "Other": { "S": { 'c': "cat" } } }; $scope.getKeys = function(obj) { return Object.keys(obj); } $scope.type = function(obj) { return typeof obj; }; }); }());
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js"></script> <div id="info" ng-app="cheat" ng-controller="maps"> <div ng-repeat="prop in getKeys(range)" ng-init="value=range[prop]"> {{prop}} = <div ng-repeat="key in getKeys(value)" ng-init="rangeValue=value[key]"> {{key}}: {{rangeValue}} </div> </div> </div>
Note: ng-init and getting the value that needs to be repeated from a function in an area is used here for demonstration purposes only. If in your actual code you just want to repeat the internal properties, you can build an array of values ββin the controller itself, iterating through the keys of the object. This will help avoid using multiple ng-repeat (unless you are doing something else with 2 repeats).
source share