It has been a real struggle for me to navigate b/w different screens/views. I have created multiple templates under the templates directory in www. I have used ng-click directive that will trigger a changePage() function under which I have written the following code:
app.controller(‘loginController’, function($scope,$state){
$scope.changePage = function () {
$state.go(‘user’);
}
});
But whenever I click on the button, the url changes but the view doesn’t. I have to explicitly reload the page in the browser to get the corresponding correct view to the url. I figure may be I need some asynchronous directive but I don’t know any. Any remedies pls? I am so pissed off.
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider,$urlRouterProvider){
$stateProvider
.state('login',{
url:'/login',
templateUrl:'templates/login.html',
controller:'loginCtrl'
})
.state('mariam',{
url:'/mariam',
templateUrl:'templates/mariam.html'
});
$urlRouterProvider.otherwise('/login');
})
.controller('loginCtrl', function($state,$scope){
$scope.go = function(path){
$location.path(path);
};
})