Create a function in your controller that gets the date as param, find the month and returns the month name and use it in the controller like:
<span class="calendar_mon">
{{someFunction(item.applicationData.EventStartDateTime)}}
</span>
then in your controller do the logic you used above:
$scope.someFunction = function(stringDate) {
var month = stringDate.split("/")[0];
var returnMonth;
switch(month) {
case "01": returnMonth = "January"; break;
case "02": returnMonth = "February"; break;
case "03": returnMonth = "March"; break;
case "04": returnMonth = "April"; break;
case "05": returnMonth = "May"; break;
case "06": returnMonth = "June"; break;
case "07": returnMonth = "July"; break;
case "08": returnMonth = "August"; break;
case "09": returnMonth = "September"; break;
case "10": returnMonth = "October"; break;
case "11": returnMonth = "November"; break;
case "12": returnMonth = "December"; break;
}
return returnMonth;
}
or even better, parse the date and get the month:
$scope.someFunction = function(stringDate) {
var parsedDate = new Date(stringDate);
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
return months[parsedDate.getMonth()];
);
or another way:
{{ someFunction(item.applicationData.EventStartDateTime) | date: "MMMM"}}
then the function in the controller, would look like:
$scope.someFunction = function(dateString) {
// you should add checks here if "dateString.split("/")[0]" returns anything
return new Date(dateString.split("/")[0]);
}
getMonth
as function inside yourng-switch
directive likeng-switch="getMonth(item.applicationData.EventStartDateTime)"
& then getMonth will return a string value