Ну в общем пытаюсь сделать по логике:
Просто запушить(Push) число в окно, типа как любое число с кнопки.
Не пойму тока как связать это значение в окне с куками.
<body ng-controller="kyk">
<p>{{ $cookies.get('cookie') }}</p>
<input type="text" ng-model="cookieVal">
<button ng-click="setCookie(cookieVal)">update</button>
<div ng-controller="CalculatorController">
<br> <span id="myFavorite" >{{formula.join('')}}</span> <br><br><br>
<button ng-click="add(7)">7</button>
<button ng-click="add(8)">8</button>
<button ng-click="add(9)">9</button>
<button ng-click="add('/')">/</button><br>
<button ng-click="add(4)">4</button>
<button ng-click="add(5)">5</button>
<button ng-click="add(6)">6</button>
<button ng-click="add('*')">*</button><br>
<button ng-click="add(1)">1</button>
<button ng-click="add(2)">2</button>
<button ng-click="add(3)">3</button>
<button ng-click="add('-')">-</button><br>
<button ng-click="add(0)">0</button>
<button ng-click="add('.')">.</button>
<button ng-click="add('+')">+</button>
<button ng-click="eval()">=</button> <br>
<button ng-click="remove()">CLEAR</button>
<button ng-click="save">SAVE</button>
<button ng-click="put(formula)">PUT</button>
</div>
app = angular.module('app',['ngCookies',])
app.controller('kyk', function ($scope, $cookies) {
$scope.$cookies = $cookies;
$scope.myCookieVal = $cookies.get('cookie');
$scope.setCookie = function (val) {
$cookies.put('cookie', val);
};
});
app.controller('CalculatorController', function ($scope, $cookies) {
$scope.$cookies = $cookies;
$scope.formula = [0];
$scope.add = function (item) {
if($scope.formula == 0) $scope.formula = [item];
else $scope.formula.push(item);
};
$scope.remove = function () {
$scope.formula.pop();
if($scope.formula = ['']) $scope.formula = [0];
};
$scope.eval = function () {
var result = eval($scope.formula.join(''));
$scope.formula = [result];
$cookies.get('formul', $scope.formula.join(''));
$cookies.put('formul', )
};
$scope.save = function() {
$cookies.get('save');
};
$scope.put = function (value) {
$cookies.put('save', value);
if($scope.formula == 0) $scope.formula =$cookies.put ('save', value);
else $scope.formula.push($cookies.put('save', value));
}
});