简体   繁体   中英

Aurelia with jquery.soap. How do I import and use the module

I'm new to the Aurelia framework.

I want to call a SOAP webservice and have found the module jquery.soap ( https://www.npmjs.com/package/jquery.soap ) to handle it.

I have added the module in my dependencies in aurelia.json

   ..."jquery",
      "jquery.soap",
      {
        "name": "bootstrap",
        "path": "../node_modules/bootstrap/dist",
        "main": "js/bootstrap.min",
        "deps": ["jquery"],
        "exports": "$",
        "resources": [
          "css/bootstrap.css"
        ]
      },...

Now I import it in app.ts and try to use it like this

import $ from "jquery.soap"

export class App {
 $.soap({
    url: 'http://my.server.com/soapservices/',
    method: 'helloWorld',

    data: {
        name: 'Remy Blom',
        msg: 'Hi!'
    },

    success: function (soapResponse) {
        console.log("success");
    },
    error: function (SOAPResponse) {
        console.log("error");
    }
 });
}

My problem is that it cannot find the module "jquery.soap"... So the question is, how to import the "jquery.soap" module in the right way? I'm also in doubt about using the module. Should it be used in app.ts or in app.html?

just import the plugin:

import 'jquery.soap';

this works fine in js, in ts you may want to import jquery to avoid warnings:

import * as $ from 'jquery';
import 'jquery.soap';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM