I have written a custom angular directive as shown below:
dirs.directive('sectionInfo', function(){
return {
restrict: 'E',
templateUrl: 'partials/section-home.html',
transclude: true,
controller: function($scope, $routeParams){
var section = this;
section.sectionItem = [];
client.entries({"some params"},
function(err, entries){
if (err) { console.log(err); return; }
$scope.$apply(function(){
section.sectionItem = entries;
});
}
);
},
controllerAs: 'sectionCtrl'
}
});
This is then displayed in a separate partial page which looks like:
<section-info></section-info>
<ul class="list-group">
<li class="list-group-item" ng-repeat="entry in entriesCtrl.index_items">
<a href="#/entries/{{entry.sys.id}}">
<h4>{{entry.fields.title}} <small>{{entry.fields.author}}</small></h4>
</a>
</li>
</ul>
With the partial template code being simply:
{{sectionCtrl.sectionItem}}
When I load this page and keep the $scope$apply call in then I get an error:
Error: error:interr Interpolation Error Can't interpolate: {{sectionCtrl.sectionItem}} TypeError: Converting circular structure to JSON
When I remove the $scope.$apply call it disappears. Any idea what is causing the circular reference within the $scope.$apply call?
EDIT: Console log of content of entries and the error message.

entries? Most likely that's causing your issue, all$applydoes in this case is tell the template it has to show the new value (entries)