I am using stringify and json is getting formatted and in alert it is coming.But in actual link it is not displaying. When I checked in console error was coming as "duplicates are not allowed in ng-repeat for the key".
Can anyone tell how to allow duplicates in ng-repeat so that formatted json will be printed.
Add 'track by $index' to the repeater.
https://docs.angularjs.org/error/ngRepeat/dupes
Related
I'am trying to hide the Json value of the student field from log files using filter-spec,
this is my filter-spec :
after i applied the flter this is how the data is showing in the log file
all i want it is to replace ("student" : "testStudent") with ("student": "****") instead it is got replaced with ("student: ****)
does anyone have an example on how to hide the json value using filter-spec?
Thanks in advance
It is not actually possible replace a JSON value with a filter. You'd need to use a custom filter or custom handler in order to do this.
You could file a feature request though. It does seem like a decent idea for a filter to be able to filter values in structured formats.
Searched everywhere but couldn't find something similar to this.
I got a table as below (a glimpse of it):
customDimensions is the column that pulls the data in JSON format. However, there are some empty cells (as seen below) in the column.
I tried to Parse the whole column into JSON but it is returning me errors in the blank columns as below:
Therefore I tried an alternative way of first replacing those blank cells in the customDimensions to a generic JSON format input as {"Type":"Unhandled"} and then Parsed the column into JSON. This successfully got rid of the errors, but it is returning error while refreshing the data!
So, How do I handle this in a different way? I want to replace those blank cells as either "null" or any keyword, as long as I do not miss the count of those blank cells.
EDIT
Re: This successfully got rid of the errors, but it is returning error while refreshing the data! The error is as follows:
And that specific error is as above
EDIT 2:
Got trapped in the XY Problem but actually you can just replace the error after parsing the JSON instead:
Repeat with all columns and it'll be fine.
I am trying to populate drop-down values using ng-repeat in Sightly. The AEM node saves my data as String array and I am able to fetch it properly, but not able to populate them as it throws "? undefined:undefined ?" error.
My code:
<select name="${validation.elementName}" id="${validation.elementName}" ng-model="${validation.elementName}" ng-change="${properties.clickfunction}">
<option ng-repeat="opt in ${properties.options}" value={{opt}}>opt</option>
</select>
And the output:
:
Is there anything I am missing? As Sightly is totally new to me. I will be very grateful for any help to improve this code or pointing my mistake.
First of all, you need to wrap the data you pass to value in quotes, so it should be like this:
value="{{opt}}"
Second, it looks like you are passing the values without single quotes and they are not being recognized as strings. Take a look at this plunker:
http://plnkr.co/edit/A2gZJbvVV9ozHloLkF4B?p=preview
You can see that the first ng-repeat works as expected, but the second throws an error in the console and doesn't display anything. Basically, you just need to put quotes around each string in your array.
Thanks #Victor for your reply.
Please find my below findings.
value="{{opt}}" was my mistake while pasting the code to stackoverflow.
${properties.options} returns string array.
ng-repeat seems to parse correctly as per this output.
I am having hard time sending some JSON data as a checkbox value. When I tried to send the JSON value, I receive only the first word as a value i.e '"{", but I need the whole chunk value. What may be the possible solutions ?
value to be send as checkbox value:
{
"audio_uri"=>
"http://testing.s3.amazonaws.com/N7jcpdkaVH-part_137768534157151.mp3",
"audio_begin_time"=>"80",
"audio_length"=>"9540",
"video_title"=>"apple_boy_cat",
"text"=>"heoolo \r\n\r\n\r\nI \r\n\r\nAm \r\n\r\n please help me..."
}
I would be grateful if anyone help me resolving this problem.
Try html escaping the json data to be sent.
For rails if your data hash is in data variable, you might wanna do CGI::escape(data.to_json) for checkbox value and when received in server side, just parse the data.
I have a google chart and want to add a custom tooltip. I found some great answers like this this site and set about doing this with roles. I also found this link about it and it looked like the best way.
My data is being generated via json and I use a php file to create a json feed. The rows I have coded like this
{"cols": [ {"id":"","label":"Period","pattern":""},
{"id":"","label":"Recorded P/L","type":"number", "role":"data"} ,
{"id":"","label": null,"type":"string", "role":"tooltip"},
{"id":"","label":"Best Available P/L","type":"number", "role":"data"},
{"id":"","label": null,"type":"string", "role":"tooltip"}
]
Then it goes on and adds all the data. The problem is when I try to run this I get the error
All series on a given axis must be of the same data type
I have checked the json and that is formed correctly but am not sure what I could be doing wrong.
At least part of your problem is that you're not specifying the type for your first column.