I have a custom directive to format datetime. I use it in multiple views and it seems to work across the board, except for one instance. When request.created is passed to it (HTML further below), the first console.log(scope) indicates "date" is correctly set and passed to the directive. But console.log(scope.date) prints empty.
I all works fine other views and several "email.sendDate"s in the same view.
The value of request is retrieved from server and set by controller.
myApp.directive('friendlydate', function () {
function link(scope, element, attrs) {
console.log(scope);
console.log(scope.date);
var uglydate = scope.date;
//do stuff
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>

Let me know if more info is required. I am on the verge of going nuts, please help.