小编Kes*_*n R的帖子

Angular 2 Material工具提示,其中的HTML内容为angular

我正在尝试将HTML字符串绑定到angular 2工具提示中。但是它以HTML形式呈现为纯字符串。有什么方法可以将字符串呈现为HTML。

这是我的代码:

在视图中:

 <span class="icon-status" mdTooltip="{{value.status}}"></span>
Run Code Online (Sandbox Code Playgroud)

零件:

value.status = this.sanitizer.bypassSecurityTrustHtml(this.getStatusTemplate(value.status));


  getStatusTemplate(status: IIconStatus): string{
let HTML =`
  <div>Event Title</div>
  <div class="">
    <table>
      <thead>
        <th>User</th>
        <th>User</th>
        <th>User</th>
        <th>User</th>
      </thead>
    </table>
  </div>
`;
return HTML;}
Run Code Online (Sandbox Code Playgroud)

提前致谢。

html javascript angular

10
推荐指数
3
解决办法
7697
查看次数

Angular - 是否可以销毁组件(不是动态创建的)?

我正在使用Angular 2谷歌地图我们的应用程序之一.我们使用套接字每5秒加载一次标记.当新标记从套接字接收时,需要删除先前的标记.Angular地图官方网站上没有适当的文件.所以想到从我们的app组件中销毁组件.我们让所有子组件找到以下代码.

import { Component, OnInit, ViewChild, ViewChildren, QueryList } from '@angular/core';
import { Socket } from 'ng2-socket-io';
import { Marker } from './google-map';
import { SebmGoogleMapMarker } from 'angular2-google-maps/core';

@Component({
  selector: 'app-google-map',
  templateUrl: './google-map.component.html',
  styleUrls: ['./google-map.component.scss'],
  providers: [SebmGoogleMapMarker]
})
export class GoogleMapComponent implements OnInit {
  public lat: number = 51.678418;
  public lng: number = 7.809007;
  public markers: Marker[] = [];
  @ViewChildren(SebmGoogleMapMarker) SebmGoogleMapMarkers: QueryList<SebmGoogleMapMarker>;
  constructor(private socket: Socket) { }

  ngOnInit() {
    this.socket.on('markers', this.setMarkers);
  }

  setMarkers = (data: Marker[]) …
Run Code Online (Sandbox Code Playgroud)

google-maps angular-google-maps angular

5
推荐指数
1
解决办法
1952
查看次数