【问题标题】:How to add angular 2 attributes inside a variable in angular 2 typescript class如何在 angular 2 typescript 类的变量中添加 angular 2 属性
【发布时间】:2017-09-12 17:10:58
【问题描述】:

我在“findCharityHome.ts”打字稿类中有一个变量“内容”,如下所示。

         let content = `
            <b>`+header+`</b>
            <button  style='background-color:#428bca;color:white;padding:5px;'>View Profile</button>
        `;  

此外,我想在上面的按钮单击事件中添加以下代码以导航到另一个页面。但是我找不到解决方案

this.navCtrl.push(myProfilePage);





这是我用 typescript 类编写的方法的完整代码。

addCluster(map){
   if(google.maps){

        //Convert locations into array of markers
        let markers = this.locations.map((location) => {
            let marker =  new google.maps.Marker({
                position: location,
                animation: google.maps.Animation.DROP,
            });
            let header = 'some';
            let content = `

            <b>`+header+`</b>
            <button  style='background-color:#428bca;color:white;padding:5px;'>View Profile</button>
            `;  
            this.addInfoWindow(marker, content);
            return marker;
        });
        this.markerCluster = new MarkerClusterer(map, markers,{imagePath: 'assets/m'});
    }
}

【问题讨论】:

    标签: angular ionic2 angular2-routing


    【解决方案1】:

    您不能在 angular 2 typescript 类的变量中添加 angular 2 属性。在您的示例中,您为变量添加了一个模板,它可能会起作用。但是 typescript 属性在这里不起作用!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-13
      • 2017-03-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-21
      • 1970-01-01
      • 2019-04-08
      • 2018-08-01
      相关资源
      最近更新 更多