I am fairly new to AngularJS and currently working with an XML file that can contain either a single record or multiple records.
When it comes to handling multiple records, ng-repeat functions smoothly as it goes through the array of objects. However, when there's only one record, it doesn't recognize it as an array (verified using angular.isArray()).
Now I'm faced with the challenge of figuring out how to address this issue.
Here is the ng-repeat code snippet:
<div class="row" ng-repeat="lessons in dataSet.module.lesson | partition:1">
<div class="col-sm-12" ng-repeat="lesson in lessons">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-title row">
<a href="" class="col-sm-12" ng-click="expandLesson(lesson);">
<div class="row">
<span class="col-sm-10">
Section #{{$parent.$index * 1 + $index + 1}}: {{lesson.title.__cdata}}
</span>
<span class="col-sm-2 text-right">
<i class="fa fa-arrow-right"></i>
</span>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
If there's a single entry in the XML File, the rendered HTML is commented out.
Log for a single object: Object {meta: Array[11], resource: Array[3], changes: Object, module: Object, title: Object…}
Log for multiple objects: [Object, Object, Object, Object, Object, Object, Object]