javascript - Redirect to another html page after JS function (Ionic, AngularJS) - Cordova -
i building android app in cordova tools visual studio using ionic , angularjs.
i want redirect html page after function has finished executing cant seem work.
heres function
if (id == null || id == undefined) { contact.save(savesuccess, saveerror); } else { contact.save(upsuccess, uperror); } function savesuccess(newcontact) { id = newcontact.id; table.insert({ contactid: id, firstname: name.givenname, lastname: name.familyname, homephone: phonenumbers[0].value, mobilephone: phonenumbers[1].value, email: emails[0].value }); alert("contact saved."); window.location("#/managermenu"); }
and heres $routprovider code.
droidsync.config(function ($routeprovider) { $routeprovider .when('/', { templateurl: 'app/pages/main.html', controller: 'maincontroller' }) .when('/addcontact', { templateurl: 'app/pages/addcontact.html', controller: 'managercontroller' }) .when('/editcontact', { templateurl: 'app/pages/editcontact.html', controller: 'managercontroller' }) .when('/deletecontact', { templateurl: 'app/pages/deletecontact.html', controller: 'managercontroller' }) .when('/managermenu', { templateurl: 'app/pages/managermenu.html', controller: 'managermenucontroller' }) .when('/settings', { templateurl: 'app/pages/settings.html', controller: 'settingscontroller' }); });
im new @ angular , js in general don't know i'm missing here...
try $state. work?
function savesuccess(newcontact, $state) { id = newcontact.id; table.insert({ contactid: id, firstname: name.givenname, lastname: name.familyname, homephone: phonenumbers[0].value, mobilephone: phonenumbers[1].value, email: emails[0].value }); alert("contact saved."); $state.go('/managermenu'); }
need state provider too
.config(function($stateprovider, $urlrouterprovider) { $stateprovider .state('managermenu', { url: '/managermenu', views: { 'managermenu': { templateurl: 'templates/managermenu.html', controller: 'managermenuctrl' } } }); });
Comments
Post a Comment