I am currently utilizing the Cordova Ionic framework to create applications for both Android and iOS platforms. One of my project requirements involves displaying the month and date on a particular page. Below is an excerpt of my code within the controller:
.controller('groupMessagesCtrl', function($scope, $stateParams, Services) {
Services.getGroupMessage($stateParams).then(function(data){
$scope.groupMessage = data.data;
});
$scope.toISOString = function(x){
return new Date(x).toISOString();
};
})
Within the HTML page:
<div class="list messages_list">
<a class="item item-avatar" ng-repeat="Message in groupMessage" href="#/app/message/{{Message.CS_MESSAGE_ID}}">
<img src="img/sample/venkman.jpg">
<h2><span class="date">{{toISOString(Message.CS_RECEIVED_DATE)}}</span>{{Message.CS_FIRST_NAME +" "+Message.CS_LAST_NAME}}</h2>
<p>{{Message.CS_MSG}}</p>
</a>
</div>
An issue arises specifically on iPhone devices when using toISOString()
function, where it returns as undefined. However, this problem does not occur with other browsers or Android applications.