1

Inside component.ts:

var bannerContent = `<div>
    Created = ${item.created_at | date}
</div>`;

Throws error on console: 'date is not defined.'

Following is also not working and prints as this as it is (without evaluating)

var bannerContent = `<div>
    Created = {{item.created_at | date}}
</div>`;

Update: Usage of this variable is like:

marker.addListener('click', function() {
  var infowindow = new google.maps.InfoWindow({content: bannerContent});
  ...
  ...
});
Jeff
  • 688
  • 1
  • 13
  • 30
Malik Shahzad
  • 6,703
  • 3
  • 37
  • 49
  • how you adding `bannerContent` in your template? – Avnesh Shakya Dec 26 '16 at 13:55
  • this bannerContent is for google maps marker. I pass this to google maps InfoWindow – Malik Shahzad Dec 26 '16 at 13:58
  • The question doesn't make sense without the context. Please, provide the code for how exactly `bannerContent` is used. If you just pass the variable to third-party API, it will obviously won't work. It should be bound in view with `[innerHTML]=...` in order to take effect. – Estus Flask Dec 26 '16 at 14:57
  • @estus Your comment make sense. But API ref of date pipe says this returns a string, and that should work: https://angular.io/docs/ts/latest/api/common/index/DatePipe-pipe.html – Malik Shahzad Dec 26 '16 at 16:34
  • It should't work because bannerContent contents aren't parsed by Angular compiler. If `item.created_at` doesn't have to be bound, you can try to apply a pipe manually to its value, e.g. http://stackoverflow.com/questions/35144821/angular-2-use-pipes-in-services – Estus Flask Dec 26 '16 at 16:48
  • Check also this http://stackoverflow.com/questions/40922224/angular2-component-into-dynamicaly-created-element – yurzui Dec 26 '16 at 16:57

0 Answers0