I have directive to change font size on page:
.directive('textSizeSlider', ['$document', function ($document) {
return {
restrict: 'E',
template: '<div class="range"><i class="icon" ng-style="{ fontSize: min + unit }">A-</i><input type="range" min="{{ min }}" max="{{ max }}" step="{{ step || 0 }}" ng-model="textSize" value="{{ value }}" /><i class="icon" ng-style="{ fontSize: max + unit }">A+</i></div>',
scope: {
min: '@',
max: '@',
unit: '@',
value: '@',
step: '@'
},
link: function (scope, element, attr) {
scope.textSize = scope.value;
scope.$watch('textSize', function (size) {
var x = document.getElementsByTagName("P");
var i;
for (i = 0; i < x.length; i++) {
x[i].style.fontSize = size + scope.unit;
}
});
}
}
}]);
On my page by button click open Popup with range to decrease/increase font size. But every time when I open Popup range slider have default position sets in value in my controller. How to save changed value for Range? This is my function in controller:
$scope.fontAdjust = function() {
var alertPopup = $ionicPopup.alert({
title: 'Font adjustment',
template: '<text-size-slider min="10" max="18" unit="px" value="14" step="0"></text-size-slider>'
})
}