Git Product home page Git Product logo

Comments (9)

chrisfraser avatar chrisfraser commented on May 12, 2024 1

@Nikhil22 Sure thing. I ran into another issue with the balance binding not updating. I will fix that on Tuesday and send something through.

from angular-truffle-starter-dapp.

 avatar commented on May 12, 2024

Using typeof window['web3'] !== 'undefined' instead of this.web3 !== 'undefined'
and using new Web3(window['web3'].currentProvider) instead of new Web3(this.web3.currentProvider) did the trick. And moving the web3 instantiating from the constructor to the hook ngAfterViewInit so that the instantiating of the web3 provider will happen after the MetaMask chrome extension is loaded (works by typing the URL in Chrome and pressing enter but does not work with a refresh (F5) or entering the same URL in the same tab again).

from angular-truffle-starter-dapp.

Nikhil22 avatar Nikhil22 commented on May 12, 2024

This is a good point, @ronh73 . The ngAfterViewInit lifecycle hook is a better use case for instantiating objects that require the view to be loaded first. I will make the changes.

from angular-truffle-starter-dapp.

 avatar commented on May 12, 2024

Thanks, that's good to hear. In my case the number of meta's is also not directly shown (could take about 10 seconds) and after a transaction the number of Meta's does not get updated. When typing the url in a new tab in Chrome, the number of Meta's shown will be correct.

By the way, I start testrpc with the -m flag with a seed. This is the same seed (aka mnemonic) that is generated by Metamask when creating an account.

from angular-truffle-starter-dapp.

chrisfraser avatar chrisfraser commented on May 12, 2024

ngAfterViewInit is still to early in the page lifecycle. You have to hook the window.load event.
lifecycle

from angular-truffle-starter-dapp.

chrisfraser avatar chrisfraser commented on May 12, 2024

You can use a HostListener as follows instead of the constructor:

@HostListener('window:load')
windowLoaded() {
  this.checkAndInstantiateWeb3();
  this.onReady();
}

from angular-truffle-starter-dapp.

Nikhil22 avatar Nikhil22 commented on May 12, 2024

@chrisfraser Can you make a PR for this? I'll add you as a contributor to the README too

from angular-truffle-starter-dapp.

chrisfraser avatar chrisfraser commented on May 12, 2024

@Nikhil22 Check out #4

from angular-truffle-starter-dapp.

Nikhil22 avatar Nikhil22 commented on May 12, 2024

@chrisfraser Thanks man, I'll review & merge you in.

from angular-truffle-starter-dapp.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.