I have a very simple solidity function only in place to transfer some ether from one address to another
function transferEtherTo(address _to) payable public {
_to.transfer(address(this).balance);
}
In remix it works as it's supposed to when Im just on the Javascript VM
But when I switch over to injected web3 I get some unexpected bugs.
For one my meta mask is showing like the ether is going to the contract's address and not the address which im trying to send it to, plus the value in meta mask is 0 for some reason while im trying to send the total contract's balance which i know for sure is 5 ether.
Here is what gets logged in my console:
transact to SimpleDapp.transferEtherTo errored: Error: Error: [ethjs-rpc] rpc error with payload {"id":41874278090,"jsonrpc":"2.0","params":["0xf88a2b8501a13b860082786c9459a42535f42048040c3f5a1152c94af40c7169db80a45c4bade1000000000000000000000000c5fdf4076b8f3a5357c5e395ab970b5b54098fef822d46a09f632a5dbe56be62a9c245f23fa62d9fd8aee230bbda026c6d5822339d2bf9b3a01b4a248bca87bcb491f6f11a572bf158ba86459336e5b1b7eb91f1dda5fde87d"],"method":"eth_sendRawTransaction"} Error: VM Exception while processing transaction: out of gas
Any idea why this works fine in the JavacsriptVM and not with injected web 3?

initWeb3: function() { if (typeof web3 !== 'undefined') { App.web3Provider = web3.currentProvider; console.log("using existing provider"); } else { App.web3Provider = new Web3.providers.HttpProvder('http://127.0.0.1:7545'); console.log("connecting to local Ganache"); } web3 = new Web3(App.web3Provider); console.log("web3 initialized"); return App.initContract(); }- benjamin852