I have developed a unique directive to format datetime that works seamlessly in multiple views, except for one specific instance. Upon passing request.created to it (as seen in the HTML below), while console.logging(scope) displays "date" correctly set and passed to the directive, console.logging(scope.date) shows an empty result.
Everything functions properly in other views and with several "email.sendDate"s within the same view.
The value of request is fetched from the server and implemented by the controller.
myApp.directive('friendlydate', function () {
function link(scope, element, attrs) {
console.log(scope);
console.log(scope.date);
var uglydate = scope.date;
//perform actions
scope.formatteddate = prettydate;
};
return {
restrict: 'E',
scope: {
date: '@'
},
link: link,
template: '{{formatteddate}}'
};
});
In my html, I have
<div class="col-md-6">
<dl class="dl-horizontal">
<dt>Created</dt>
<dd>
<friendlydate date="{{request.created}}"></friendlydate>
</dd>
<dt>IP Address</dt>
<dd>{{request.ipAddress}}</dd>
<dt>Browser</dt>
<dd>{{request.browser}}</dd>
</dl>
</div>
<table>
<tbody ng-repeat="email in request.emails">
<tr>
<td>
<friendlydate date="{{email.sendDate}}"></friendlydate>
</td>
<td>{{email.subject}}</td>
<td>{{emailStatus(email.status)}}</td>
<td><button class="btn btn-primary">view</button></td>
</tr>
</tbody>
</table>
If more information is needed, feel free to ask. I am close to losing my mind, please provide assistance.