javascript - Add class in angular on ng-repeat when item is contained on array -
on angular controller have array of events:
vm.events = [ { date: "18-02-2016", name: "event a" }, { date: "18-02-2016", name: "event c" }, { date: "24-02-2016", name: "event d" } ];
and have array of days in current month:
var days = [ { date: "01-02-2016" }, { date: "02-02-2016" }, { date: "03-02-2016" } ... ];
on angular view have following:
<span class="day" ng-class="{ 'today': istoday(day) }" ng-repeat="day in vm.days">{{getday(day)}}</span>
how can add class span when day has events, e.g., when day has @ least 1 record in vm.events?
here solution:
<div ng-repeat="day in days"> <span ng-class="{true:'today', false: 'day' } [istoday(day.date)]"> {{day.date}} : {{istoday(day.date)}} </span> </div>
check working plunker
Comments
Post a Comment