Module 14: Adding Toast-Style Notifications

  1. Add the toast plugin to your project:

    $ ionic plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin
    
  2. Add a function to handle displaying a toast message in the AppCtrl in controllers.js. The code will fall back on an ionic sort of hack to display a similar type of toast message when testing in the browser.

    function showToast(message) {
            if (window.plugins && window.plugins.toast) {
                window.plugins.toast.showShortCenter(message);
            }
            else $ionicLoading.show({ template: message, noBackdrop: true, duration: 2000 });
        }
    

    Now it can be called from where it's needed using:

    showToast($scope.msg);