Skip to content

Commit

Permalink
Calculations in place
Browse files Browse the repository at this point in the history
  • Loading branch information
tostartpressanykey committed Mar 27, 2015
1 parent 1dd9ce4 commit 356deb2
Show file tree
Hide file tree
Showing 4 changed files with 5,732 additions and 68 deletions.
22 changes: 19 additions & 3 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,25 @@ angular
// set app to have pretty URLS
$locationProvider.html5Mode(true);
})
.controller('MainController', function() {
.controller('MainController', function($scope) {
var vm = this;
vm.og = 1.06;
vm.abv = 7.77;
vm.reading = {}; // stores og, fg, abv

vm.message = 'To Alcohol the cause of and solution to all of life\'s problems!';

vm.abvFormula = function(readings) {
// ( ( 1.05 x ( OG – FG ) ) / FG ) / 0.79 x 100 = % ABV
return (( 1.05 * ( readings.og - readings.fg )) / readings.fg) / 0.79 * 100;
}

vm.calculateABV = function() {
console.log(this.reading);
if(this.reading.og !== undefined && this.reading.fg !== undefined) {
this.reading.abv = this.abvFormula(this.reading);

}
}



});
Loading

0 comments on commit 356deb2

Please sign in to comment.