Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular demo could have simpler strategy #20

Open
jrodl3r opened this issue Jul 10, 2021 · 0 comments
Open

Angular demo could have simpler strategy #20

jrodl3r opened this issue Jul 10, 2021 · 0 comments

Comments

@jrodl3r
Copy link

jrodl3r commented Jul 10, 2021

Why not use this approach (until a proper Angular-specific package arrives)?

  • include the JS files in /assets/js/
  • add JS files to angular.json (projects » architect » build » options » scripts)
  • add moralisAppId + moralisUrl to environments
  • setup app.component.ts:
import { Component } from '@angular/core';
declare const Moralis: any;
export class AppComponent {
  constructor() {
    Moralis.initialize(environment.moralisAppId);
    Moralis.serverURL = environment.moralisUrl;
  }

  connect(): void {
    Moralis.Web3.authenticate().then(function (user:any) {
      console.log(user.get('ethAddress'));
    });
  }
}
  • add button to app.component.html: <button (click)="connect()">Connect</button>

Seems a lot easier, less confusing than trying to get a node script to run in Angular 11+ without ejecting Webpack. Let me know what you think 👍

@jrodl3r jrodl3r changed the title Angular demo app does not work + could have better strategy Angular demo could have simpler strategy Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant