Ionic Enlarge Font Size - angularjs

I've seen it on several apps, but can't seem to figure it out. I simply want to place a icon for font (with + and -) where the user clicks it, it will enlarge the font size or decrease it.

Working plunker.
controllers.js
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope) {
$scope.size = 14;
$scope.fontSize = "font-size-" + $scope.size;
$scope.increase = function(){
//Higher limit
if($scope.size < 18){
$scope.size++;
$scope.fontSize = "font-size-" + $scope.size;
}
};
$scope.decrease = function(){
//Lower limit
if($scope.size > 14){
$scope.size--;
$scope.fontSize = "font-size-" + $scope.size;
}
};
});
tab-dash.html
<ion-view view-title="Dashboard">
<ion-content class="padding" ng-class="fontSize">
<button class="button" ng-click="increase()"><i class="ion-plus-round"></i></button>
<button class="button" ng-click="decrease()"><i class="ion-minus-round"></i></button>
<div class="list card">
<div class="item item-divider">Recent Updates</div>
<div class="item item-body">
<div>
There is a fire in <b>sector 3</b>
</div>
</div>
</div>
<div class="list card">
<div class="item item-divider">Health</div>
<div class="item item-body">
<div>
You ate an apple today!
</div>
</div>
</div>
<div class="list card">
<div class="item item-divider">Upcoming</div>
<div class="item item-body">
<div>
You have <b>29</b> meetings on your calendar tomorrow.
</div>
</div>
</div>
</ion-content>
</ion-view>
style.css
.font-size-14 *{
font-size: 14px;
}
.font-size-15 *{
font-size: 15px;
}
.font-size-16 *{
font-size: 16px;
}
.font-size-17 *{
font-size: 17px;
}
.font-size-18 *{
font-size: 18px;
}
I added the lower and higher limits so an user can't go over these two font-sizes.

Related

Angular UI Bootstrap multiple carousel one by one

I am using AngularJS with ui bootstrap module.
1) What I need is my carousel to change its items one by one. I found a code (by other person) but it's only in jQuery.
Codepen code in jQuery
html:
<div class="container">
<h1>Use Bootstrap's carousel to show multiple items per slide.</h1>
<div class="row">
<div class="col-md-12">
<div class="carousel slide multi-item-carousel" id="theCarousel">
<div class="carousel-inner">
<div class="item active">
<div class="col-xs-4"><img src="http://placehold.it/300/f44336/000000" class="img-responsive"></div>
</div>
<div class="item">
<div class="col-xs-4"><img src="http://placehold.it/300/e91e63/000000" class="img-responsive"></div>
</div>
<div class="item">
<div class="col-xs-4"><img src="http://placehold.it/300/9c27b0/000000" class="img-responsive"></div>
</div>
<div class="item">
<div class="col-xs-4"><img src="http://placehold.it/300/673ab7/000000" class="img-responsive"></div>
</div>
<div class="item">
<div class="col-xs-4"><img src="http://placehold.it/300/4caf50/000000" class="img-responsive"></div>
</div>
<div class="item">
<div class="col-xs-4"><img src="http://placehold.it/300/8bc34a/000000" class="img-responsive"></div>
</div>
<!-- add more items here -->
<!-- Example item start: -->
<div class="item">
<div class="col-xs-4"><img src="http://placehold.it/300/8bc34a/000000" class="img-responsive"></div>
</div>
<!-- Example item end -->
</div>
<a class="left carousel-control" href="#theCarousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="right carousel-control" href="#theCarousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>
</div>
</div>
less CSS:
.multi-item-carousel{
.carousel-inner{
> .item{
transition: 500ms ease-in-out left;
}
.active{
&.left{
left:-3%;
}
&.right{
left:3%;
}
}
.next{
left: 3%;
}
.prev{
left: -3%;
}
#media all and (transform-3d), (-webkit-transform-3d) {
> .item{
// use your favourite prefixer here
transition: 500ms ease-in-out left;
transition: 500ms ease-in-out all;
backface-visibility: visible;
transform: none!important;
}
}
}
.carouse-control{
&.left, &.right{
background-image: none;
}
}
}
jQuery
$('.multi-item-carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
if (next.next().length>0) {
next.next().children(':first-child').clone().appendTo($(this));
} else {
$(this).siblings(':first').children(':first-child').clone().appendTo($(this));
}
});
2) So I want multiple items change one bye one. How to do this in angularJS? Any ideas or directions?

How I can share the value between two pages in ionic v-1

I am trying to add the value of both pages on selection.
It is adding on individual pages. But while I am moving to the next page the Total value comes Zero. I am trying to add pass total added value from one page to another page.
As I search , I found that there is a need to create a service controller to call a global scope value.
<!-- page one view page -->
<ion-content class="search-main padding">
<div class="list card">
<div class="item item-body no-padding stable">
<div class="row no-padding border-bottom" ng-controller="Ctrl3">
<div class="col padding border-right" ng-click="openDateCheckIn()">
<div class="margin-bottom-10" style="color:#0c60ee;"><i class="icon icon-money"></i> Total Value =></div>
</div>
<div class="col padding"><h2 style="text-align:center; margin-top: 3px;">Rs. <b>{{rootSum()}}</b></h2></div>
</div>ass="col padding"><h2 style="text-align:center; margin-top: 3px;">Rs. {{rootSum()}}</h2></div>
</div>
<div ng-controller="Ctrl1">
<div ng-repeat="gender in genders">
<div class="row row-no-padding no-margin padding-important" style="color: #000;">
<div class="col col-70"><i class="ion ion-ios-circle-filled"></i> <span> {{gender.id}}</span></div>
<div class="col col-20"><span>Rs {{gender.value}}</span></div>
<div class="col col-10"><div><label class="search-checkbox item item-checkbox" style="margin: -5px 0px 0px -2px;"><div class="checkbox checkbox-input-hidden disable-pointer-events checkbox-circle"><input id="{{gender}}" type="checkbox" value="{{gender.value}}" ng-checked="selection.indexOf(gender) > -1" ng-click="toggleSelection(gender)" /><i class="checkbox-icon"></i></div><div class="item-content disable-pointer-events" ng-transclude=""></div></label></div>
</div></div>
</div></div>
</ion-content>
<!-- Page two view page -->
<ion-content class="search-main padding">
<div class="list card">
<div class="item item-body no-padding stable">
<div class="row no-padding border-bottom" ng-controller="Ctrl3">
<div class="col padding border-right" ng-click="openDateCheckIn()">
<div class="margin-bottom-10" style="color:#0c60ee;"><i class="icon icon-money"></i> Total Value =></div>
</div>
<div class="col padding"><h2 style="text-align:center; margin-top: 3px;">Rs. <b>{{rootSum()}}</b></h2></div>
</div>
<div ng-controller="Ctrl2">
<div ng-repeat="gender in genders">
<div class="row row-no-padding no-margin padding-important" style="color: #000;">
<div class="col col-70"><i class="ion ion-ios-circle-filled"></i> <span> {{gender.id}}</span></div>
<div class="col col-20"><span>Rs {{gender.value}}</span></div>
<div class="col col-10"><div><label class="search-checkbox item item-checkbox" style="margin: -5px 0px 0px -2px;"><div class="checkbox checkbox-input-hidden disable-pointer-events checkbox-circle"><input id="{{gender}}" type="checkbox" value="{{gender.value}}" ng-checked="selection.indexOf(gender) > -1" ng-click="toggleSelection(gender)" /><i class="checkbox-icon"></i></div><div class="item-content disable-pointer-events" ng-transclude=""></div></label></div>
</div></div>
</div></div>
</div>
</div>
</ion-content>
Controller page --
//Ladies Makeup Party
.controller('Ctrl1', function($scope ,$rootScope) {
$scope.genders=[{
'id':'Krylon Party Makeup', 'value':2000 },
{'id':'Makeup Studio', 'value':2200 },
{'id':'Party Makeup(MAC)', 'value':2500 },
{'id':'Party Mackeup(Airbrush)', 'value':3500 }
];
$rootScope.selection=[];
$scope.toggleSelection = function toggleSelection(gender) {
var idx = $scope.selection.indexOf(gender);
if (idx > -1) {
$scope.selection.splice(idx, 1);
}
else {
$scope.selection.push(gender);
}
};
})
//Ladies Makeup Pre-bridal
.controller('Ctrl2', function($scope ,$rootScope) {
$scope.genders=[{
'id':'Silver', 'value':10000 },
{'id':'Gold', 'value':12000 },
{'id':'Platinum', 'value':16000 }
];
$rootScope.selection=[];
$scope.toggleSelection = function toggleSelection(gender) {
var idx = $scope.selection.indexOf(gender);
if (idx > -1) {
$scope.selection.splice(idx, 1);
}
else {
$scope.selection.push(gender);
}
};
})
// Add total value on select
.controller('Ctrl3', function($scope ,$rootScope) {
$rootScope.rootSum=function(){
var total=0;
for(var i = 0; i < $rootScope.selection.length; i++){
var product = $rootScope.selection[i];
total += (product.value);
}
return total
};
}) *
There are two problems I can see here.
You are initialising $rootScope.selection = [] at every controller, this deletes all previous changes. Initialise it at start of page load inside run block.Use this link to implement run run.
myApp.run(function() {
console.log("app run");
});
You are not transferring selected data to $rootScope.selection variable. You need to append your selected product in rootScope and make sure no item is repeated. Instead of array, I recommend you to use object with 'ids' as attrinute name, this will ensure that no item is repeated inherently.

ionic data randomly don't display

I'm devloping an aplication on ionic using api when I go on a certain view the first time some data sometimes don't display. however the data seem to have no problem to load.
here a screenshot of my problem :
controller.js :
.controller('activite', function($http,$state,settings,$scope,$rootScope,ActiFactory,EventFactory)
{
console.log('ActiFactory',ActiFactory);
evenement_selectionne=ActiFactory.evenement_selectionne;
$scope.evenement_selectionne=evenement_selectionne;
activite_selectionne=ActiFactory.activite_selectionne;
$scope.activite_selectionne=activite_selectionne;
}
activite.html :
<ion-view>
<ion-nav-title>
{{activite_selectionne.nom_activite}}
</ion-nav-title>
<ion-content padding="true" class="has-header">
<form class="list">
<label class="item item-input">
<span class="input-label">
{{evenement_selectionne.lieu}}, {{evenement_selectionne.date}}. {{activite_selectionne.heure_activite}}.
</span>
</label>
</form>
<div>
{{activite_selectionne.description}}
</div>
<div>
nombre d'inscrits : {{activite_selectionne.inscris.length}}/{{activite_selectionne.limit_particip_activ}}
</div>
<button style="color:#FFFFFF;" ng-click="inscription()" class="button button-balanced button-block icon-right ion-arrow-right-c">
S'inscrire à cet évenement !
</button>
<img src="{{activite_selectionne.image}}" style="display: block; width: 100%; height: auto; margin-left: auto; margin-right: auto;">
</ion-content>
</ion-view>
thank you in advance

How to responsive image in ionic from different screen size?

I am creating an ionic app, in that I need to add a four images in my home page in two row and each row has two images. The images size is 296*296.
I have tried the below code,
index.html
<ion-nav-view class="container" >
</ion-nav-view>
Home.html
<ion-view view-title="HOME">
<ion-content>
<div class="row" >
<div class="col-md-6 " id="img1">
<img src="img/hard.png" class="img-responsive " id="img1" >
</div>
<div class="col-md-6" id="img1">
<img src="img/soft.png" class="img-responsive " id="img1">
</div>
</div>
<div class="row" >
<div class="col-md-6 " id="img1">
<img src="img/welcome.png" class="img-responsive " id="img1" >
</div>
<div class="col-md-6" id="img1">
<img src="img/title.png" class="img-responsive " id="img1">
</div>
</div>
</ion-content>
</ion-view>
CSS
#img1{
width: 100%;
height: auto
}
Your ids for div and img are same i.e img1. Change the id and then try. And make width and height important may be some other css overwrites it. Tell me if this works or not.
#img2{
width: 100% !important;
height: auto !important;
}
<div class="col-md-6 " id="img1">
<img src="img/hard.png" class="img-responsive " id="img2" >
</div>
I also got this issue. This code might help to you
HTML
<div class="list card new-feeds wall-post">
<div class="row">
<div class="col">
<div class="item item-image img4">
<img src="img/hard.png">
</div>
<div class="item item-image img4">
<img src="img/soft.png">
</div>
<div class="item item-image img4">
<img src="img/welcome.png">
</div>
<div class="item item-image img4">
<img src="img/title.png">
</div>
</div>
</div>
</div>
css
.wall-post .img4 {
width: 50%;
float: left;
height: 120px;
}
.img4 > img {
height: 100%;
width: 100%;
object-fit: cover;
}

AngularJS Bootstrap make the datetimer picker responsive

I am trying to make the datetimepicker responsive for bootstrap but having issues.
I have seen this plugin:
https://github.com/niftylettuce/bootstrap-datepicker-mobile#requirements
which would be great to use in my application, but the problem is my application doesn't use jQuery (nor do I want it to).
I have the datepicker set up like this:
<div class="col-md-4">
<div ng-model="controller.today" datepicker ng-change="controller.getArchive()"></div>
</div>
Does anyone know how I can make the datetimepicker responsive without using jQuery?
Well I managed to fix this myself.
I created my own templates which looked like this:
<script id="template/datepicker/datepicker.html" type="text/ng-template">
<div class="datepicker" ng-switch="datepickerMode" role="application" ng-keydown="keydown($event)">
<daypicker ng-switch-when="day" tabindex="0"></daypicker>
<monthpicker ng-switch-when="month" tabindex="0"></monthpicker>
<yearpicker ng-switch-when="year" tabindex="0"></yearpicker>
</div>
</script>
<script id="template/datepicker/day.html" type="text/ng-template">
<div>
<div class="row">
<div class="col-xs-2">
<button class="btn btn-default btn-block" ng-click="move(-1)" tabindex="-1"><span class="fa fa-chevron-left"></span></button>
</div>
<div class="col-xs-8">
<button class="btn btn-default btn-block" ng-click="toggleMode()" ng-disabled="datepickerMode === maxMode" tabindex="-1">{{ title }}</button>
</div>
<div class="col-xs-2">
<button class="btn btn-default btn-block"><span class="fa fa-chevron-right"></span></button>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="flexbox">
<div ng-repeat="label in labels track by $index">
<small aria-label="{{ label.full }}">{{ label.abbr }}</small>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="flexbox" ng-repeat="row in rows track by $index">
<div ng-repeat="dt in row track by dt.date">
<button class="btn btn-default btn-block" ng-class="{'btn-info': dt.selected, active isactive(dt)}" ng-click="select(dt.date)" ng-disabled="dt.disabled" tabindex="-1"><span ng-class="{'text-muted': dt.secondary, 'text-info' dt.current}">{{ dt.label }}</span></button>
</div>
</div>
</div>
</div>
</div>
</script>
Then I created 2 SASS files, one for the actual datepicker:
.datepicker {
text-align: center;
.row {
> div {
padding-left: 1px;
padding-right: 1px;
&:first-child {
padding-left: 15px;
}
&:last-child {
padding-right: 15px;
}
}
> .col-xs-12,
> .col-sm-12,
> .col-md-12,
> .col-lg-12 {
padding-left: 15px;
padding-right: 15px;
}
}
.flexbox {
margin-top: -1px;
&:first-child {
margin-top: 2px;
}
}
}
and a flexbox one:
.flexbox {
display: flex;
> div {
-ms-flex: 1 auto;
flex: 1 auto;
margin-left: -1px;
&:first-child {
margin-left: 0;
}
}
}
This solved my issue.
I will update this when I have all templates replaced and I will add a jsfiddle.

Resources