I have the following code snippet, where I have added a reset function that I want to be able to use from ng-click in any part of any template.
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hiding the accessory bar by default (you can remove this to show the accessory bar above the keyboard for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
$ionicPlatform.reset = function(path) {
console.log("hello")
// $location.path( path );
};
})
I am attempting to use it in index.html, but nothing seems to happen.
<ion-nav-bar class="bar-stable nav-title-slide-ios7">
<ion-nav-back-button class="button-icon icon ion-ios7-arrow-back">
Back
</ion-nav-back-button>
<ion-nav-buttons side="right">
<button class="button button-clear button-positive" ng-click="reset()">
Refresh
</button>
</ion-nav-buttons>
</ion-nav-bar>
Am I doing this incorrectly? How can I make a function accessible in all controllers?