Adrian Ber
Adrian Ber

Reputation: 21390

Cordova plugin in Angular 4 Typescript application

I want to use the cc.fovea.cordova.purchase plugin in an Angular4 application + Cordova.

I added the plugin to config.xml:

<platform name="android">
    ...
    <plugin name="cc.fovea.cordova.purchase" spec="https://github.com/j3k0/cordova-plugin-purchase.git">
        <param name="BILLING_KEY" value="XXX"/>
    </plugin>
</platform>

I also added typed-cordova-plugin-purchase to devDependencies in package.json and to typeRoots in tsconfig.json.

When I'm trying

import { store, IStore, IProduct } from "cc.fovea.cordova.purchase";

I get

Module not found: Error: Can't resolve 'cc.fovea.cordova.purchase'

What is the correct way of using a Cordova plugin in an Angular 4 Typescript app?

Upvotes: 1

Views: 1799

Answers (1)

Adrian Ber
Adrian Ber

Reputation: 21390

I had to do one more thing, add node_modules/typed-cordova-plugin-purchase to typeRoots and typed-cordova-plugin-purchase to types in tsconfig.json.

Upvotes: 2

Related Questions