I'm trying to encode a string that's pretty complex, so that I can include it in a mailto:
Component:
<a href="mailto:[email protected]?subject='Hello'&{{body}}">
TS:
import { HttpParameterCodec } from "@angular/common/http";
let body = encodeValue('This is the example body\nIt has line breaks and bullets\n\u2022bullet one\n\u2022bullet two\n\u2022bullet three')
When I try to use encodeValue, I get "cannot find name encodeValue.
How would be best to url-encode body?
encodeURI
function which should encode your text. (If you're using one of the characters -;,/?:@&=+$#
, please use theencodeURIComponent
function instead.) – Embrey