controllers.js
var vanapp = angular.module(‘starter.controllers’, [‘ngRoute’])
.config(function($routeProvider) {
$routeProvider
.when(’/’, {
templateUrl:‘login.html’
})
.when(’/app/dashboard’, {
resolve: {
“check”: function($location, $rootScope) {
if(!$rootScope.loggedIn){
$location.path(’/’);
}
}
},
templateUrl:‘dashboard.html’
})
.otherwise({
redirectTo: ‘/’
});
})
.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, $location, $rootScope, $ionicPopup) {
$scope.submit = function(){
if($scope.username == 'admin' && $scope.password == 'admin'){
$rootScope.loggedIn = true;
$location.path('/app/dashboard');
} else {
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(‘ContactCtrl’, function($scope, $http) {
$scope.sendContact = function() {
var data = {
fistname: this.contact.fistname,
lastname: this.contact.lastname,
email: this.contact.email,
phone: this.contact.phone,
message: this.contact.message
};
console.log(data);
$http.post("http://192.168.1.189/app_dev.php/api/contact/", data);
}
});