UNPKG

ionic-cordova-gulp-seed

Version:

Ionic & Cordova & Gulp seed with organized code, tests, bower support and some other stuff. Originated from ionic-angular-cordova-seed.

31 lines (28 loc) 690 B
--- name: simple component: ionToggle --- var app = angular.module('simple', ['ionic']); app.controller('MainCtrl', function($scope) { $scope.pizza = { pepperoni: true, sausage: false, anchovies: true, jalapenos: false }; $scope.toppings = function() { var toppings = Object.keys($scope.pizza).filter(function(flavor) { return $scope.pizza[flavor]; }); if (toppings.length > 1) { toppings[toppings.length - 1] = 'and ' + toppings[toppings.length - 1]; } if (toppings.length > 2) { return toppings.join(', '); } else if (toppings.length) { return toppings.join(' '); } else { return 'nothing'; } }; });