zoukankan      html  css  js  c++  java
  • Ionic3报错Error: Uncaught (in promise): Error: StaticInjectorError

    ERROR Error: Uncaught (in promise): Error: StaticInjectorError[Geolocation]:
    StaticInjectorError[Geolocation]:
    NullInjectorError: No provider for Geolocation!
    Error: StaticInjectorError[Geolocation]:
    StaticInjectorError[Geolocation]:
    NullInjectorError: No provider for Geolocation!
    at _NullInjector.get (core.js:923)
    at resolveToken (core.js:1211)
    at tryResolveToken (core.js:1153)
    at StaticInjector.get (core.js:1024)
    at resolveToken (core.js:1211)
    at tryResolveToken (core.js:1153)
    at StaticInjector.get (core.js:1024)

    不能调用获取位置的组件Geolocation

    这个问题的关键是没有添加 提供者provider

    解决办法是在 app.module.ts中添加这个依赖

    import {Geolocation} from '@ionic-native/geolocation';
    ...
    @NgModule({
    ...
    providers: [
      Geolocation,
      ]
    })
    ...

    import { Camera } from '@ionic-native/camera';
    
    ...
    
    @NgModule({
        ...
    
        providers: [
        ...
        Camera
        ...
    ]
    ...
    })
    export class AppModule { }

    原创文章,欢迎转载,转载请注明出处!

  • 相关阅读:
    Nio笔记(一)
    设计模式之职责链模式
    Hibernate注解(三)
    Hibernate注解(二)
    Hibernate注解(一)
    设计模式之适配器模式
    设计模式之桥接模式
    设计模式之外观模式
    设计模式之观享元模式
    设计模式之观察者模式
  • 原文地址:https://www.cnblogs.com/acm-bingzi/p/ionicPromise.html
Copyright © 2011-2022 走看看