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.

5
  • Try attaching the JSON object to $scope then itterate through it with ng-repeat. check this topic for some reference [stackoverflow.com/questions/21697695/… Commented May 16, 2016 at 9: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 Commented May 16, 2016 at 9:44
  • Ah I see, let me explore it a bit and i will get back to you. Commented May 16, 2016 at 9: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?? Commented May 16, 2016 at 9:59
  • You might be better of just making an $http request and save the result to $scope variable, i assume that after i read stackoverflow.com/questions/34300193/… and docs.angularjs.org/api/ng/directive/ngInit. Commented May 16, 2016 at 10:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.