I need something like this, but it doesn't work
.directive('dateTime', function(){
return {
restrict: 'E',
replace: true,
scope:'=value',
template: "<div>{{value.format('mmm dd yy')}}"</div>",
// ^here: applying a function to the scope
};
});
You've created an isolate scope with scope: '=value' so this is a brand new scope that does not prototypically inherit from the parent scope. This means that any functions you want to call must be from
require to get access (see the tabs and pane directives on the Angular home page for an example)You might just be looking for the date filter:
{{value | date:'MMM dd yy'}}
but you can do this too:
app.directive('dateTime', function(){
return {
restrict: 'E',
replace: true,
scope:'=value',
template: "<div>{{value | date:'MMM dd yy')}}"</div>",
// ^here: applying a function to the scope
};
});