0

I have a scenario where I have to loop through the JSON string in template. I tried these 2 solutions but none of them are working properly: 1. Create a filter and pass it to ng-init:

< div ng-init="var1 = (COL_FIELD | FormatJson)"> 
<span ng-repeat="wut_detail in var1.wu_tester_detail"> {{wut_detail}}</span> </div>

Above filter converts the string to JSON object properly, but ng-init seems to be working abnormally it doesn't refreshes data properly on search.

Can anyone please help, how I can change the variable COL_FIELD to JSON object in the template without using ng-init.

undefined
  • 3,464
  • 11
  • 48
  • 90
  • Try attaching the JSON object to `$scope` then itterate through it with ng-repeat. check this topic for some reference [http://stackoverflow.com/questions/21697695/angularjs-ng-repeat-access-key-and-value-from-json-array-object] – Vladimir Drenovski May 16 '16 at 09:41
  • I cannot attach this to scope variable because there can be more than 5000 diff values for COL_FIELD. It will hung the browser – undefined May 16 '16 at 09:44
  • Ah I see, let me explore it a bit and i will get back to you. – Vladimir Drenovski May 16 '16 at 09:51
  • Can I see page with complete son file?? Have you assigned `COL_FIELD` json value to a Scope variable?? Are you sure browser hanged that time?? – Jenson M John May 16 '16 at 09:59
  • You might be better of just making an `$http` request and save the result to `$scope` variable, i assume that after i read http://stackoverflow.com/questions/34300193/angular-ng-init-injecting-data-via-server-side-scripting and https://docs.angularjs.org/api/ng/directive/ngInit. – Vladimir Drenovski May 16 '16 at 10:02

0 Answers0