Based on your comment that you need to insert the array into the database, I'm going to assume that you are converting it a JSON string and then saving it to the DB. If that's incorrect, let me know and I'll see if I can revise this answer.
You have two options for modifying your array when converting it to JSON. The first is angular.toJson
, which is a convenience method that automatically strips out any property names with a leading $$
prior to serializing the array (or object). You would use it like this:
var json = angular.toJson( $scope.appdata );
The other option, which you should use if you need more fine grained control, is the replacer
argument to the built-in JSON.stringify
function. The replacer function allows you to filter or alter properties before they get serialized to JSON. You'd use it like this to strip $$hashKey
:
var json = JSON.stringify( $scope.appdata, function( key, value ) {
if( key === "$$hashKey" ) {
return undefined;
}
return value;
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…