Comments (9)
@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.
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.
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.
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.
ngAfterViewInit
is still to early in the page lifecycle. You have to hook the window.load event.
from angular-truffle-starter-dapp.
You can use a HostListener as follows instead of the constructor:
@HostListener('window:load')
windowLoaded() {
this.checkAndInstantiateWeb3();
this.onReady();
}
from angular-truffle-starter-dapp.
@chrisfraser Can you make a PR for this? I'll add you as a contributor to the README too
from angular-truffle-starter-dapp.
from angular-truffle-starter-dapp.
@chrisfraser Thanks man, I'll review & merge you in.
from angular-truffle-starter-dapp.
Related Issues (9)
- angular version HOT 1
- Transaction event? HOT 3
- Refactor into Services
- Gets stuck estimating transaction costs HOT 1
- Deploy contract HOT 2
- Error: ParserError: Source file requires different compiler version HOT 3
- rename truffle.js to truffle-config.js ? HOT 1
- Web3 is always detected as being injected
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-truffle-starter-dapp.