angular.module(‘starter.controllers’, [])
.service(‘detailService’, function() {
this.itemName;
this.itemface;
this.itemdescription;
this.itemlastText;
})
.controller(‘AppCtrl’, function($scope, $ionicModal, $timeout) {
// With the new view caching in Ionic, Controllers are only called
// when they are recreated or on app start, instead of every page change.
// To listen for when this page is active (for example, to refresh data),
// listen for the $ionicView.enter event:
//$scope.$on(’$ionicView.enter’, function(e) {
//});
})
.controller(‘LoginCtrl’, function($scope, LoginService, $ionicPopup, $state) {
$scope.data = {};
$scope.login = function() {
LoginService.loginUser($scope.data.username, $scope.data.password).success(function(data) {
$state.go('app.dashboard');
}).error(function(data) {
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
}
})
.controller(‘RegistreerCtrl’, function($scope, $stateParams) {
})
.controller(‘ForgotpasswordCtrl’, function($scope, $stateParams) {
})
.controller(‘PlaylistsCtrl’, function($scope,detailService) {
$scope.playlists = [
{ title: ‘Reggae’, face: ‘img/ben.png’, description: ‘Lorem Ipsum is simply dummy text of the printing and typesetting industry’, lastText: ‘Pubished on:’, id: 1 },
{ title: ‘Chill’, face: ‘img/max.png’, description: ‘Lorem Ipsum is simply dummy text of the printing and typesetting industry’, lastText: ‘Pubished on:’, id: 2 },
{ title: ‘Dubstep’, face: ‘img/adam.png’, description: ‘Lorem Ipsum is simply dummy text of the printing and typesetting industry’, lastText: ‘Pubished on:’, id: 3 },
{ title: ‘Indie’, face: ‘img/perry.png’, description: ‘Lorem Ipsum is simply dummy text of the printing and typesetting industry’, lastText: ‘Pubished on:’, id: 4 },
{ title: ‘Rap’, face: ‘img/mike.png’, description: ‘Lorem Ipsum is simply dummy text of the printing and typesetting industry’, lastText: ‘Pubished on:’, id: 5 },
{ title: ‘Cowbell’, face: ‘img/ben.png’, description: ‘Lorem Ipsum is simply dummy text of the printing and typesetting industry’, lastText: ‘Pubished on:’, id: 6 }
];
$scope.getDetail=function(ObjectData){
detailService.itemName=ObjectData.title;
detailService.itemface=ObjectData.face;
detailService.itemdescription=ObjectData.description;
detailService.itemlastText=ObjectData.lastText;
}
})
.controller(‘PlaylistCtrl’, function($scope,$stateParams,detailService) {
$scope.detailService=detailService;
})
.controller(‘DashboardCtrl’, function($scope, $stateParams) {
})
.controller(‘MapCtrl’, function($scope, $ionicPlatform, $cordovaGeolocation, $ionicLoading) {
$ionicPlatform.ready(onDeviceReady);
function onDeviceReady() {
$ionicLoading.show({
template: '<ion-spinner icon="bubbles"></ion-spinner><br/>Acquiring location!'
});
var posOptions = {
enableHighAccuracy: true,
timeout: 50000,
maximumAge: 0
};
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
var myLatlng = new google.maps.LatLng(28.580004, 77.319665);
var mapOptions = {
center: myLatlng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
$scope.map = map;
$ionicLoading.hide();
}, function(err) {
$ionicLoading.hide();
console.log(err);
});
}
});