小编Har*_*vix的帖子

如何在Angular 4中实现Google Maps API(initMap)?

我尝试在Angular中集成Google地图.

的index.html

<script async defer src="https://maps.googleapis.com/maps/api/js?key=api_key&callback=initMap"></script>
Run Code Online (Sandbox Code Playgroud)

example.component.html

...
<div id="map"></div>
...
Run Code Online (Sandbox Code Playgroud)

example.component.ts

...
ngAfterViewInit() {
        function initMap() {
            var uluru = {lat: -25.363, lng: 131.044};
            var map = new google.maps.Map(document.getElementById('map'), {
                zoom: 4,
                center: uluru
            });
            var marker = new google.maps.Marker({
                position: uluru,
                map: map
            });
        }
    }
Run Code Online (Sandbox Code Playgroud)

我仍然得到错误"initMap不是一个函数".

google-maps angular

6
推荐指数
1
解决办法
4043
查看次数

Angular 2:URL 中的“router.navigate”编码错误

当我提交表单时,我想导航到另一个站点并将 URL 中的搜索值设置为参数。

我有以下代码:

searchOffers() {
    this.router.navigate([
      '/search?query= +
        this.search.value.FG
    ]);
  }
Run Code Online (Sandbox Code Playgroud)

此代码有效,但路由后的 URL 如下所示。

localhost:4200/search%3Fquery%3D1 
Run Code Online (Sandbox Code Playgroud)

query参数值为1)。

使用此 URL,我无法获取参数。

如何将 URL 格式化为:localhost:4200/search?query=1

angular2-routing angular

5
推荐指数
2
解决办法
4052
查看次数

在*ngIf中使用属性绑定

我有一个数组,其中包含商品有图像名称的信息.随着*ngIf它应该显示任何图像或"无图像".但内部的属性绑定*ngIf不起作用.这甚至可能吗?

<div class="m-c-o" *ngFor="let offer of offers">

    <div class="m-c-p" *ngIf="showOffers">
      <div class="m-c-img-c">
        <img *ngIf="{{ offer.U_D__IMAGE }} != false" src="{{ imagePath + offer.U_D__IMAGE }}">
        <div *ngIf="{{ offer.U_D__IMAGE }} === false">
          <i class="materials-icons">photo_camera</i>
          <div class="m-c-img-ni">No Images</div>
        </div>
      </div>
    </div>

 </div
Run Code Online (Sandbox Code Playgroud)

angular

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

标签 统计

angular ×3

angular2-routing ×1

google-maps ×1