标签: angular13

ngx-translate:检测语言变化的事件(Angular)

我想使用ngx-translate库检测“当前语言”的切换。

我可以使用哪个 js 事件来实现这一点?

为了更好地理解我的意思,请检查这个简单的示例: https: //stackblitz.com/edit/github-yvbmgu

我想在 ngOnInit() 上检测“diff”组件中 currentLang 的变化。

typescript angular-components ngx-translate angular angular13

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

Angular 地图标记集群组件不起作用

我按如下方式使用地图,但这不起作用

<google-map #googleMap width="100%" height="100%" (idle)="initClusterer($event)">
  <map-marker-clusterer *ngIf="googleMap?.googleMap">
    <ng-container *ngFor="let i of items">
      <ng-container *ngIf="i.categories | haveCategory: targetCategory">
        <map-marker #markerElem [position]="i.position"> </map-marker>
      </ng-container>
    </ng-container>
  </map-marker-clusterer>
</google-map>
Run Code Online (Sandbox Code Playgroud)
import { MarkerClusterer } from '@googlemaps/markerclusterer'

//...

@ViewChild('googleMap', { static: true }) googleMap: GoogleMap
markerCluster?: MarkerClusterer

// ...

initClusterer(e) {
    console.log('initClusterer', e)
    if (!this.googleMap?.googleMap || this.markerCluster) return

    console.log(this.googleMap, this.googleMap.googleMap)
    this.markerCluster = new MarkerClusterer({
      map: this.googleMap.googleMap,
      markers: this.markerElem,
    })
}
Run Code Online (Sandbox Code Playgroud)

我确实下载了以下依赖项 npm i @googlemaps/markerclusterer
npm i @types/google.maps --save-dev

而不是markerclustererplus,因为它已被弃用。

但我收到以下错误。

vendor.js:91237 ERROR Error: MarkerClusterer class …
Run Code Online (Sandbox Code Playgroud)

google-maps markerclusterer angular angular13

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

尝试在 Angular 13 中实现 AWS Cognito 身份验证

尝试以 Angular 13 (alias) const Amplify 实现 AWS cognito Authentication: AmplifyClass import Amplify 'default' is deprecated.ts(6385) index.d.ts(18, 4): 该声明在此处被标记为已弃用。您能建议需要做什么或任何其他简单的集成方法吗?

angular13

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

让 Angular Ngif 中的变量具有多个条件

在 Angular (13) 中,有一种方法可以将函数的结果分配给在ngIf中具有多个条件.html的变量(在组件的一部分,而不是 template

<div *ngIf="let getMyVar() as myVar && isVisible && isClean">
    {{ 'this is myVar: ' + myVar }}
</div>
Run Code Online (Sandbox Code Playgroud)

如果不是,可以实施什么解决方法?

javascript angular angular13

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