谷歌地图InfoWindow withAurelia

时间:2017-06-16 12:59:25

标签: google-maps aurelia

我有一个问题,我想显示某些信息,具体取决于信息是否为空。

infowindow.setContent(`<b show.bind="${info != null}> Info : ${info}</b>`);

我似乎无法让它发挥作用。这有可能吗?

1 个答案:

答案 0 :(得分:0)

我们假设info是您班级的属性:

 
import { observable } from 'aurelia-framework'; 

export class MyClass {

  // if the property is not bindable you should use @observable, otherwise you just keep @bindable
  @observable() 
  private info: string;

  private infoChanged() {
    const content = info ? `<b> Info : ${info}</b>` : ''; 
    infowindow.setContent(content);
  }
}

这比增强更容易,并将解决问题。