JSFiddle - React, Tailwind, and code Playground
by Zonedark
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"></script>
<div ng-controller="MyCtrl">
You are using {{name}}
<div>
<div>
{{Money}} $
</div>
<button ng-click="Money = Money + ClickIncome">
$
</button>
<button ng-click="IncreaseClick()">
C++ => {{ClickPrice}} $
</button>
<button ng-click="IncreaseIncome()">
I++ => {{IncomePrice}} $
</button>
</div>
</div>
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('MyCtrl', ['$scope', '$interval', function($scope, $interval) {
$scope.name = "Angular";
$scope.Money = 0;
$scope.Income = 0;
$scope.ClickIncome = 1;
$scope.IncomePrice = 50;
$scope.ClickPrice = 50;
//Increase income value
$scope.IncreaseIncome = function() {
if ($scope.Money >= $scope.IncomePrice) {
$scope.Money = $scope.Money - $scope.IncomePrice;
$scope.IncomePrice = $scope.IncomePrice + (Math.floor($scope.IncomePrice / 10));
$scope.Income = $scope.Income + 1;
}
}
//Increase click value
$scope.IncreaseClick = function() {
if ($scope.Money >= $scope.ClickPrice) {
$scope.Money = $scope.Money - $scope.ClickPrice;
$scope.ClickPrice = $scope.ClickPrice + (Math.floor($scope.ClickPrice / 2));
$scope.ClickIncome = $scope.ClickIncome + 1;
}
}
stop = $interval(function() {
$scope.Money = $scope.Money + $scope.Income;
}, 1000);
}]);