1

I have the following files.

index.js

...
completedTooltip = 'Completed on 2019-02-02T23:59:59-07:00';
...

index.html

...
{{completedTooltip | date : 'MM/dd/yyyy'}}
...

The date doesn't get formatted here and just spits out the string.

Is there any way I can make this work OR do I have to just have 2 separate vars so that one var can hold the text and the other can hold the date?

1 Answer 1

2

You can create custom filter,

app.filter("anyName", function($filter) {
  return function(input, format) {
    var txtArr = input.split(' ');
    txtArr[2] = $filter('date')(txtArr[2], format);
    return txtArr.join(' ');
  };
});

And use that in your HTML

{{completedTooltip | anyName : 'MM/dd/yyyy'}}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.