I would like to be able to use the Angular2 template syntax when building a Google Maps InfoWindow.
As far as I can tell, this means passing a a component as a template string to the content property in the InfoWindow constructor object.
If this is the case, I believe I need to stringify the component template. Is this correct (and possible)?
Here is an example of what I think I need to do:
// Component
import {Component} from 'angular2/core';
import {Thing} from './something/in/my/app/thing.model.ts';
@Component({
selector: 'my-infowindow',
template: `<p>This is an infowindow for {{ something.name }}</p>`
})
export class MyInfoWindowComponent {
constructor(public something: Thing) {}
}
// Implementation
import {Thing} from './something/in/my/app/thing.model.ts';
import {MyInfoWindowComponent} from './path/to/infowindow.component';
/* { ...stuff... } */
private _buildInfoWindow(thing: Thing): google.maps.InfoWindow {
return new google.maps.InfoWindow({
/* v this is what I want v */
content: new MyInfoWindowComponent(thing).toString()
/* ^ this is what I want ^ */
});
}
ElementRef: angular.io/docs/ts/latest/api/core/ElementRef-class.html orViewChild: angular.io/docs/ts/latest/api/core/ViewChild-var.htmlngIfandngFor). Does that make sense?ElementReflike @Langley explained and useinnerHTML. Using Angular as string template builder is extremely inefficient compared to stringbuilder.