angular.module('starter.controllers', [])

.controller('AppCtrl', function($scope, $ionicModal, $timeout, User, $state) {
  // 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) {
  //});

  // Form data for the login modal
  $scope.loginData = {};

  // Create the login modal that we will use later
  $ionicModal.fromTemplateUrl('templates/login.html', {
    scope: $scope
  }).then(function(modal) {
    $scope.modal = modal;
    $scope.modal.show();
  });

  // Triggered in the login modal to close it
  $scope.closeLogin = function() {
    $scope.modal.hide();
  };

  // Perform the login action when the user submits the login form
  $scope.login = function() {
    User.loginUser($scope.user)
    .success(function(user){
      console.log(user);
      User.setActiveUser(user);
      $scope.closeLogin();
      $scope.go('^.featured');
    }).
    catch(function(error){
      console.log(error);
    });
  };

  $scope.register = function(){
    $scope.modal.hide();
    $state.go('^.register');
  }
})

.controller('RegisterCtrl', function($scope, User) {
  $scope.register = function(user){
    User.registerUser(user)
    .success(function(user){
      User.setActiveUser(user);
    })
    .catch(function(error){
      console.log(error);
    });
  }
})
.controller('VenuesCtrl', function($scope, User, Venue) {
  $scope.$on('$ionicView.enter', function(e) {
    Venue.getVenues()
    .success(function(venues){
      console.log(venues);
      $scope.venues = venues;
    })
    .catch(function(error){
      console.log(error);
    });
  });
})
.controller('ArtistsCtrl', function($scope, User, Artist) {
  $scope.$on('$ionicView.enter', function(e) {
    Artist.getArtists()
    .success(function(artists){
      console.log(artists);
      $scope.artists = artists;
    })
    .catch(function(error){
      console.log(error);
    });
  });
})
.controller('VenueCtrl', function($scope, $state, User, Venue) {
  $scope.$on('$ionicView.enter', function(e) {
    Venue.getVenue($state.params.username)
    .success(function(venue){
      console.log(venue);
      $scope.venue = venue;
    })
    .catch(function(error){
      console.log(error);
    });
  });
})
.controller('ArtistCtrl', function($scope, $state, User, Artist) {
  $scope.$on('$ionicView.enter', function(e) {
    Artist.getArtist($state.params.username)
    .success(function(artist){
      console.log(artist);
      $scope.artist = artist;
    })
    .catch(function(error){
      console.log(error);
    });
  });
})
;

@@ -2754,10 +2754,727 @@
  %7D);%0A%7D)%0A
+.controller('FeaturedCtrl', function($scope, $state, User, Artist, Events) %7B%0A  $scope.$on('$ionicView.enter', function(e) %7B%0A    // Artist.getArtist($state.params.username)%0A    // .success(function(artist)%7B%0A    //   console.log(artist);%0A    //   $scope.artist = artist;%0A    // %7D)%0A    // .catch(function(error)%7B%0A    //   console.log(error);%0A    // %7D);%0A  %7D);%0A%7D)%0A.controller('BookingCtrl', function($scope, $state, User, Artist, Events) %7B%0A  $scope.$on('$ionicView.enter', function(e) %7B%0A    // Artist.getArtist($state.params.username)%0A    // .success(function(artist)%7B%0A    //   console.log(artist);%0A    //   $scope.artist = artist;%0A    // %7D)%0A    // .catch(function(error)%7B%0A    //   console.log(error);%0A    // %7D);%0A  %7D);%0A%7D)%0A
 ;%0A

add skeleton controllers for booking and feature pages