Reputation: 2129
I have this in my HTML:
<iframe src="https://kart.1881.no/?direction={59.83006424|6.25588723|START}{{{latitude}}|{{longitude}}|M%C3%85L}"></iframe>
Notice
{{{latitude}}
- Here I want to escape the first {
I tried to put \{
but it not work as well.
The error is Missing expected : at the end of the expression
Upvotes: 3
Views: 11241
Reputation: 10613
Use the +
operator to concatenate the required SRC
[src]="...{' + {{latitude}}+ '}...'"
(Update: added brackets to src
)
Upvotes: 0
Reputation: 994
Use the html entity {
<iframe src="https://kart.1881.no/?direction={59.83006424|6.25588723|START}{{{latitude}}|{{longitude}}|M%C3%85L}"></iframe>
Upvotes: 0
Reputation: 214047
view
<iframe [src]="'https://kart.1881.no/?direction={59.83006424|6.25588723|START}{' + latitude + '|' + longitude + '|M%C3%85L}' | safe"></iframe>
And the next pipe should help you
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer} from '@angular/platform-browser';
@Pipe({ name: 'safe' })
export class SafePipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {}
transform(url) {
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
}
You can override interpolation like
template: `
<iframe src="https://kart.1881.no/?direction={59.83006424|6.25588723|START}{[[latitude]]|[[longitude]]|M%C3%85L}"></iframe>
`,
interpolation: ['[[', ']]']
but anyway you have to sanitize url
that will work only with property(not interpolation) binding
Upvotes: 1
Reputation: 1917
You could try with %7B
for {
and %7D
for }
. Those are just the URI-encoded forms, which Angular shouldn't try to parse.
Upvotes: 3