angular.module('toster', [])
.controller('DemoCtrl', function() {
var vm = this;
vm.type = 'fruits';
vm.types = ['fruits', 'vegetables'];
vm.fruits = ['apple', 'orange', 'banana'];
vm.vegetables = ['potato', 'tomato', 'cucumber'];
});
<body ng-controller="DemoCtrl as demo">
<div>
<select ng-model="demo.type" ng-options="type as type for type in demo.types">
</select>
<p>
Selected: <span ng-bind="demo.type"></span>
</p>
</div>
<div>
<select ng-model="demo.value" ng-options="item as item for item in demo[demo.type]">
</select>
<p>
Selected: <span ng-bind="demo.value"></span>
</p>
</div>
</body>
$locationChangeSuccess
Broadcasted after a URL was changed.
The newState and oldState parameters may be defined only in HTML5 mode and when the browser supports the HTML5 History API.
angular.module('events.services', [])
.factory('EventService', function($http, $cordovaSQLite) {
return {
getDataFromDB: function() {
var query = 'SELECT id, title, img, coords, details, dateString, timestamp FROM events ORDER BY timestamp DESC';
return $cordovaSQLite.execute(db, query);
}
}
})
angular.module('toster', [])
.controller('GridCtrl', function() {
var vm = this;
var grids = [
{
xs: '12',
sm: '6',
md: '4',
lg: '4'
},
{
xs: '10',
sm: '8',
md: '6',
lg: '3'
}
];
var activeIndex = 0;
vm.activeGrid = grids[activeIndex];
vm.toggleGrid = function() {
switch (activeIndex) {
case 0:
vm.activeGrid = grids[++activeIndex];
break;
case 1:
vm.activeGrid = grids[--activeIndex];
break;
}
};
})
.directive('dynamicGrid', function() {
return {
scope: {
grid: '=dynamicGrid'
},
templateUrl: 'dynamicGrid.html',
link: function(scope, elem) {
scope.$watch('grid', function(grid) {
var gridCss = {};
angular.forEach(grid, function(value, key) {
gridCss['col-' + key + '-' + value] = true;
});
scope.gridCss = gridCss;
});
}
};
});