Skip to content

Instantly share code, notes, and snippets.

@IamAdamJowett
Last active February 3, 2017 23:50
Show Gist options
  • Save IamAdamJowett/21b1ce0993b5b695b5d8 to your computer and use it in GitHub Desktop.
Save IamAdamJowett/21b1ce0993b5b695b5d8 to your computer and use it in GitHub Desktop.
Useful Ionic 1 Framework tips and tricks

###Restore an Ionic App to state left by other developer

This will restore any platforms and cordova plugins listed in the package.json file under cordovePlugins and cordovaPlatforms. These are platforms and plugins added via ionic platform add and ionic plugin add rather than via npm (which live in platforms and plugins in the package.json file).

ionic state restore

###Change the network address for live preview

Sometimes you need to switch which network address live preview is going to listen to on ionic run --device -l or ionic serve --lab calls, this can be done by:

ionic address

Disable the Ionic side menu swipe on a per view basis

The following placed in a views controller will disable the swiping of an Ionic side menu, and enabled it again when you leave.

function disableSideMenuSwipe() {
    $scope.$on('$ionicView.enter', function() {
        $ionicSideMenuDelegate.canDragContent(false);
    });
    $scope.$on('$ionicView.leave', function() {
        $ionicSideMenuDelegate.canDragContent(true);
    });
}

Update and existing project with new Ionic libs

Have a squiz in your www/lib/ionic folder and see if there are any bower files there. If there are, delete them, then return to the root of your ionic project and run:

ionic lib update -d

Which should kick off the process. Without deleting the bower files within the ionic folder (seem to be there from older pre-rc versions), it will kick out of the process without updating your version.

To check the version after updating, run ionic lib -v

Don't add current screen to history when navigation away

In some instances, such as splash screens, fork screens or welcome screens, you don't want the back button when a selection is made as the destination the user is going to will be acting as their 'home' screen. Do stop this screen being added to history, use:

$ionicHistory.nextViewOptions({
    disableAnimate: true,
    disableBack: true
});

Hide the scroll bar

If you want to ensure the scroll bar is not shown on a page, perhaps because you have disabled programatically the scrolling capabilities under certain situations, use the following css:

.scroll-bar-indicator {
	display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment