Firebase.push failed: first argument contains an invalid key ($$hashKey)

前端 未结 6 1162
太阳男子
太阳男子 2021-02-02 13:42

I recently started learning AngularJS+Firebase. I\'m trying to write in my firebase an object like this:

{
    title: \"Personal Information\",
    say: [
               


        
6条回答
  •  再見小時候
    2021-02-02 14:11

    The best way to get rid of the $$hasKeys is to use "track by" in ng-repeats as in the following (as mentioned in the answer above)

    ...

    but you can also set track as par of ng-model-options

    ng-model-options="{ trackBy: '$value.someKeyOnYourObject' }"
    

    on a form control. This way also improves performance of your angular app.

    Another way is to remove the $$hashKey is using

    angular.copy(someObj);

    If all else fails, you could also use lodash to remove the keys that start with the "$".

    _.omitBy(yourObject, function(value, key){return _.startsWith(key, '$');});
    

提交回复
热议问题