, API- API, AngularJS, , <<20 > $
. , , !:)
. $scope.obj
:
$scope.obj = $scope.obj.map(function(cur) {
return renameKey(cur)
})
, renameKey
, , Array
Object
, x
, $
function renameKey(cur) {
if(isArray(cur)) {
cur.forEach(function(obj) {
obj = renameKey(obj)
})
} else if (isObject(cur)) {
for (let key in cur) {
if(key.charAt(0) === '$') {
cur['x'+key] = cur[key];
delete cur[key];
}
cur[key] = renameKey(cur[key])
}
}
return cur
}
function isObject(obj) {
return obj && (typeof obj === "object");
}
function isArray(obj) {
return isObject(obj) && (obj instanceof Array);
}
, ! , , x$t
$t
HTML !