I have an Angular date variable today
that I'm using the date pipe on, like so:
{{today | date:'LLLL d'}}
February 13
However, I would like to make it appear like this:
13 days so far in February
When I try a naive approach to this, I get this result:
{{today | date:'d days so far in LLLL'}}
13 13PM201818 18o fPMr in February
This is because, for instance d
refers to the day.
How can I escape these characters in an Angular date pipe? I tried \d
and such, but the result did not change with the added backslashes.
Escape CharactersUse the backslash character to escape a single character or symbol. Only the character immediately following the backslash is escaped. Note: If you use braces to escape an individual character within a word, the character is escaped, but the word is broken into three tokens.
\ is a special character within a string used for escaping. "\" does now work because it is escaping the second " . To get a literal \ you need to escape it using \ .
ASCII escape character The ASCII "escape" character (octal: \033 , hexadecimal: \x1B , or ^[ , or, in decimal, 27 ) is used in many output devices to start a series of characters called a control sequence or escape sequence.
? The backslash character ( \ ) is the escaping character. It can be used to denote an escaped character, a string, literal, or one of the set of supported special characters. Use a double backslash ( \\ ) to denote an escaped string literal.
How about this:
{{today | date:'d \'days so far in\' LLLL'}}
Anything inside single quotes is ignored. Just don't forget to escape them.
This works for me {{today | date:"d 'days so far in' LLLL"}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With