Ionic + AngularJS - Fiddle
HTML
<link rel="stylesheet" href="http://code.ionicframework.com/1.0.0-beta.9/css/ionic.min.css">
<script src="http://code.ionicframework.com/1.0.0-beta.9/js/ionic.bundle.min.js"></script>
CSS
.selected{
color:black;
font-weight: 600;
}
JavaScript
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
var starter = angular.module('starter', ['ionic']);
starter.directive('increase', function($rootScope)
{
return {
link: function(scope, elm, attrs) {
elm.bind("click", function()
{
if ($rootScope.total_selected == $rootScope.maximum_selectable)
{
// scope.openModal();
scope.showAlertMax();
return false;
}
// console.log('scope.parfum.quantite ->');
// console.log(scope.parfum.quantite);
// return(scope.parfum.quantite);
scope.$apply(function() {
scope.parfum.quantite = scope.parfum.quantite + 1;
});
$rootScope.$apply(function() {
$rootScope.total_price = $rootScope.total_price + scope.parfum.prix;
$rootScope.total_selected = $rootScope.total_selected + 1;
});
});
}
}
});
starter.directive('decrease', function($rootScope)
{
return {
link: function(scope, elm, attrs) {
elm.bind("click", function()
{
if (scope.parfum.quantite < 1)
{
return false;
}
// console.log('scope.parfum.quantite ->');
// console.log(scope.parfum.quantite);
// return(scope.parfum.quantite);
scope.$apply(function() {
scope.parfum.quantite = scope.parfum.quantite - 1;
...