I am new to the angular js field, and am trying to pick up the basics: I have a JSON that I want sorted into 4 or 5 separate parent divs depending on a value in the JSON, and then have the JSON fill this div with the values information. What is the best practice in ANGULAR to grab this data and sort it. I understand dom manipulation in JQUERY, but how should I do this in angular? Here is my sample code that uses JQLITE: Sample:
//events is a predefined JSON loaded from API
angular.module('NerdCtrl', []).controller('NerdController', function($scope) {
$scope.events = events;
for(var i = 0; i < events.length; i++)
{
var a = new Date(events[i].start.dateTime);
if(a.getDay() == 2 )
{
angular.element( "#tuesday" ).append(angular.element('card'+i));
}
}
});
<div class="ui container">
<div class="ui grid">
<div id="monday"class="two wide column">Monday</div>
<div id="tuesday"class="two wide column">Tuesday</div>
<div id="wednesday"class="two wide column">Wednesday</div>
<div id="thursday"class="two wide column">Thursday</div>
<div id="friday"class="two wide column">Friday</div>
<div id="saturday"class="two wide column">Saturday</div>
<div id="sunday"class="two wide column">Sunday</div>
</div>
</div>
<div ng-repeat="x in events "class="ui cards ">
<div class="card " id="card{{$index}}" >
<div class="content ">
<div class="header">
{{x.summary}}
</div>
<div class="meta">
{{x.location}}
</div>
<div class="description">
{{x.start.dateTime}}
</div>
</div>
<div class="extra content">
<div class="ui two buttons">
<div class="ui basic green button">Approve</div>
<div class="ui basic red button">Decline</div>
</div>
</div>
</div>
</div>
I was wondering if there was a more efficient way to do this as the DOM operations will be costly, and it feels like a work around.