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 { }

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

  • 相关阅读:
    [luoguP2622] 关灯问题II(状压最短路)
    [luoguP2016] 战略游戏(DP)
    FileUpload
    Mysql -- JDBC
    Mysql优化
    Mysql锁
    Mysql索引
    Mysql事务
    Mysql基本语句
    Listener
  • 原文地址:https://www.cnblogs.com/acm-bingzi/p/ionicPromise.html
Copyright © 2011-2022 走看看