Open liquidcms opened 5 years ago
I saw an old post of someone looking for jDrupal support for Angular 2. I'm a bit late but i got this working with Angular 4 (TypeScript).
npm install jdrupal
in angular.json under "scripts" i added: "node_modules/jdrupal/jdrupal.js"
using an import statement should have worked but i couldn't figure it out.
then in mypage.page.ts
import { Component, OnInit } from '@angular/core'; // import * as Drupal from 'jdrupal'; declare var Drupal: any; @Component({ selector: 'app-drupal-test', templateUrl: './drupal-test.page.html', styleUrls: ['./drupal-test.page.scss'], }) export class DrupalTestPage implements OnInit { constructor() {} ngOnInit() { Drupal.settings.site_path = 'http://qleva.liquidcms.org'; Drupal.settings.endpoint = 'rest'; this.initDrupal(); this.userLogin(); } initDrupal() { system_connect({ success: function(result) { // Prepare a message for the user. const text = result.user.uid === 0 ? 'Hello World' : 'Hello ' + result.user.name; // Show the message in the paragraph. document.getElementById('msg').innerHTML = text; } }); } userLogin() { user_login('qleva-admin', 'qpoiqpoi', { success:function(result) { document.getElementById('useremail').innerHTML = result.user.mail; }, error:function(xhr, status, message) { alert(message); } }); } }
Not exactly sure what system_connect() does. Don't think it is really needed for anything.
I saw an old post of someone looking for jDrupal support for Angular 2. I'm a bit late but i got this working with Angular 4 (TypeScript).
npm install jdrupal
in angular.json under "scripts" i added: "node_modules/jdrupal/jdrupal.js"
using an import statement should have worked but i couldn't figure it out.
then in mypage.page.ts