Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors under Ionic #36

Open
cocaybica opened this issue Sep 14, 2021 · 3 comments
Open

Errors under Ionic #36

cocaybica opened this issue Sep 14, 2021 · 3 comments

Comments

@cocaybica
Copy link

cocaybica commented Sep 14, 2021

Hi,

I'm trying to use ng-canvas-gauges in my Ionic 5 (capacitor) test blank page. Installed using npm install ng-canvas-gauges

Importing the module in app.module.ts gives me:

NG0304: 'radial-gauge' is not a known element:
1. If 'radial-gauge' is an Angular component, then verify that it is part of this module.
2. If 'radial-gauge' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

Removing the import from app.module.ts and adding to home.module.ts gives me two errors:

ERROR TypeError: Cannot read properties of undefined (reading 'update')
    at RadialGauge$1.basicUpdate (ng-canvas-gauges.js:242)
    at RadialGauge$1.initGauge (ng-canvas-gauges.js:222)
    at RadialGauge$1.ngAfterViewInit (ng-canvas-gauges.js:158)
    at callHook (core.js:2526)
    at callHooks (core.js:2495)
    at executeInitAndCheckHooks (core.js:2446)
    at refreshView (core.js:9535)
    at refreshComponent (core.js:10635)
    at refreshChildComponents (core.js:9261)
    at refreshView (core.js:9514)
ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'nativeElement')
TypeError: Cannot read properties of undefined (reading 'nativeElement')
    at RadialGauge$1.get options [as options] (ng-canvas-gauges.js:65)
    at RadialGauge$1.ngOnInit (ng-canvas-gauges.js:321)
    at callHook (core.js:2526)
    at callHooks (core.js:2495)
    at executeInitAndCheckHooks (core.js:2446)
    at refreshView (core.js:9479)
    at refreshComponent (core.js:10635)
    at refreshChildComponents (core.js:9261)
    at refreshView (core.js:9514)
    at renderComponentOrTemplate (core.js:9578)
    at resolvePromise (zone.js:1255)
    at resolvePromise (zone.js:1209)
    at zone.js:1321
    at ZoneDelegate.invokeTask (zone.js:434)
    at Object.onInvokeTask (core.js:28692)
    at ZoneDelegate.invokeTask (zone.js:433)
    at Zone.runTask (zone.js:205)
    at drainMicroTaskQueue (zone.js:620)

This is my app.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { HomePage } from './home.page';

import { HomePageRoutingModule } from './home-routing.module';

import { GaugesModule } from 'ng-canvas-gauges';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule, 
    GaugesModule,
    HomePageRoutingModule  
  ],
  declarations: [HomePage]
})
export class HomePageModule {}

My home.page.html

<ion-header [translucent]="true">
  <ion-toolbar>
    <ion-title>
      Blank
    </ion-title>
  </ion-toolbar>
</ion-header>

<ion-content [fullscreen]="true">
  <p>Gauges</p>
  <radial-gauge width="400" height="400"></radial-gauge>
</ion-content>
@Make-It-Racing
Copy link

Trying to achieve the same, did you manage to solve it?

@cocaybica
Copy link
Author

Not using this. But there is a fork that it is working:
https://github.com/biacsics/ng-canvas-gauges

You can read my Ionic forum post:
https://forum.ionicframework.com/t/is-not-a-known-element-error/214853

@Make-It-Racing
Copy link

I did find that post and was able to setup the fork.
I have another question :-) In order to update the value of the gauge dynamically I just use angular binding to update the attribute of the gauge:
<radial-gauge id="gauge-ps" [attr.value]="myValueProperty">
Is there a better way to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants