mircobabini
7/11/2014 - 5:21 PM

Simple Navigation Controller for AngularJS + Ionic; provides goBack(), goHome()

Simple Navigation Controller for AngularJS + Ionic; provides goBack(), goHome()

angular.module('app.controllers', [])
.controller('NavController', function($scope, $ionicSideMenuDelegate, Navigator) {
  $scope.goBack = function() {
    $ionicNavBarDelegate.back();
  };
  
  // just for this demo
  $scope.goHome = function() {
    Navigator.home();
  };
})


angular.module('app.services', [])
.factory('Navigator', function ($location) {
  return{
    go: function(path){
      $location.path(path);
    },
    
    // delete or edit to fit your needs
    home: function(){
      this.go('/');
    }
  };
})
            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
 
 Copyright (C) 2014 MIRCO BABINI <mircobabini.com>
 
 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.
 
            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
  0. You just DO WHAT THE FUCK YOU WANT TO.