0

An example of the data that I am using:

[
  {  
   objectId: "lBrweaVVKd"
   url: "http://files.parsetfss.com/5f0d29c3-6b71-4029-8bd8-c2db01a82bbc/tfss-cf720b16-08f9-46ed-b23e-1e626aImage"
  },
  {
   objectId: "lBrweaVVKd"
   url: "http://files.parsetfss.com/5f0d29c3-6b71-4029-8bd8-c2db01a82bbc/tfss-cf720b16-08f9-46ed-b23e-1e626aImage"
  }
]

and using an ng-repeat in my template like so:

<div ng-repeat="image in activeExercise.images track by $index" ng-model="activeExercise.images">
    <img ng-if="isNumber(image)" src="http://file.s3.amazonaws.com/medium/{{image}}.jpg" />
    <img ng-if="!isNumber(image)" src="{{image.url}}"></div>
</div>

(I return my images from two locations, one is local and is just an image, and the other in parse.com which is a URL hence my ng-if unsure if this is causing my problems?)

When I push this into an array the ng-repeat is producing $$hash.

The problem with this is Parse.com rejects anything with a $ in it

== EDIT == This is a sample of code where track by $index does not produce $$hash

    <ion-slide ng-repeat="sliderimage in activeExercise.images track by $index">
        <div ng-if="isNumber(sliderimage)" image-lazy-src="http://rehabgurufiles.s3.amazonaws.com/medium/{{sliderimage}}.jpg"></div>
        <div ng-if="!isNumber(sliderimage)" class="modalSliderThumbnail" image-lazy-src="{{sliderimage.url}}"></div>
    </ion-slide>

== EDIT 2 == The help a little more:

This receives a number :

<div ng-if="isNumber(sliderimage)" image-lazy-src="http://urufiles.s3.amazonaws.com/medium/{{sliderimage}}.jpg">

This receives an object as described above:

<img ng-if="!isNumber(image)" src="{{image.url}}"></div>
Taylorsuk
  • 1,419
  • 1
  • 16
  • 51
  • is the div also in your ionic project? or are there 2 different versions of angular being used? – jsuser Jul 02 '15 at 21:05
  • Yes - this is all the same app. The slide `` version is just a different way of displaying the same thing as the `
    ` version.
    – Taylorsuk Jul 02 '15 at 21:07
  • it seems like it's using the same array to populate the images. I created a plnkr to see if having multiple ng-repeats over the same array causes the $hash but wasn't able to duplicate. Are images being added to the `activeExercise.images` the same way? i.e. using the same method? – jsuser Jul 02 '15 at 21:31

1 Answers1

0

Angular adds the $$hashKey See this SO post

You need to remove this before you send the data to parse. delete itm.$$hashKey would work in your function before sending the data

Community
  • 1
  • 1
jsuser
  • 411
  • 4
  • 10
  • 1
    Ideally I would like it not to every be in my object - I understood that `track by $index` would stop it being added? – Taylorsuk Jul 02 '15 at 20:43
  • 1
    I have read that as well, that track by will make it so $$hashKey is not added. I have not personally tested this. – jsuser Jul 02 '15 at 20:44
  • I use `track by $index` elsewhere in my app and it has worked to correct this problem elsewhere in my app however it is not working in this case. – Taylorsuk Jul 02 '15 at 20:45
  • Do you have a sample of your code where track by $index is being used and the $$hashKey isn't being added? – jsuser Jul 02 '15 at 20:52