UNPKG

ionic-angular

Version:

[![Circle CI](https://circleci.com/gh/driftyco/ionic.svg?style=svg)](https://circleci.com/gh/driftyco/ionic)

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'; } }; });