1

I get my html template + json data from xsl translator , it is dynamic , it looks like html code plus some data in stringified json. The question is: in what way i put the json string in html code , so that controller will catch this json data before html rendering? When i simple put it like this:

<div>{{ $scope.categories = [{},{},...]}}</div>
<div ng-repeat="category in categories" class="category">...</div>

it works good , but brings some strange error:

Error: 10 $digest() iterations reached. Aborting!

So what is the good way to pass data from view to controller?

Ivan Chernykh
  • 41,617
  • 13
  • 134
  • 146
  • Can you show how you get JSON data? Do you use [`$http`](http://docs.angularjs.org/api/ng.$http)? – the-lay May 23 '13 at 10:00
  • @the_lay like this: `$routeProvider.when('/categories', { templateUrl: 'retrieve_xml.php?Xsl=categories.xsl', controller: 'CategoriesCtrl' })` – Ivan Chernykh May 23 '13 at 10:07
  • Can you show `CategoriesCtrl`? What is `
    {{ $scope.categories = [{},{},...]}}
    ` for?
    – Dan May 23 '13 at 15:32
  • @sh0ber CategoriesCtrl is still empty function . i want to pass it some data after the template is loaded. – Ivan Chernykh May 23 '13 at 16:59
  • @Cherniv I can suggest you make it a little bit another way: in controller put `$http.get(retrieve_xml.php?Xsl=categories.xsl).success(function (result) { $scope.categories = result; }`. This way categories variable will have all the data it got from your .xml file and then it can properly render html. – the-lay May 24 '13 at 06:58
  • @Cherniv oh and in `$routeProvider` in `templateUrl` put your html partial view file, not the file you want to get. – the-lay May 24 '13 at 06:59
  • @the_lay thank you for suggestion. i thought about the way you noted but i want to make it in one call to server. may be there is some way to catch data that route getting from server and parse it before the view is rendered? – Ivan Chernykh May 24 '13 at 11:31

0 Answers0