Sondes Sondes - 1 year ago 84
AngularJS Question

AngularJS change location is not working

I'm new in ionic
I'm trying to do a simple switch between two views in a login app:


<ion-header-bar class="bar-stable">
<h1 class="title">Ionic Login App</h1>

<div class="list list-inset">
<label class="item item-input">
<input type="text" placeholder="Email" ng-model="">
<label class="item item-input">
<input type="password" placeholder="Password" ng-model="data.password">
<button class="button button-block button-calm" ng-click="postLogin()">Login</button>



app.controller('loginCtrl', function ($scope,$http,$location)

$ = {};
$scope.postLogin = function ()

var data =
email: $,
password: $

$"http://localhost/authproject/public/api/auth/login", data)
// success callback

// failure callback




When I click on a button Login the url change but the page doesn't change

Could someone tell me how do I solve this ? Thanks in advance :)

Answer Source

In your app.js add a state for map like this (with your own templateUrl and controller value). Make sure to add $stateProvider in the config(). Also, include ui.router to your dependencies. Something like this:

angular.module('starter', ['ionic', 'starter.controllers', 'starter.directives', 'ui.router'])
    .config(function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider){

       .state('map', {
        url: '/map',
        templateUrl: 'app/views/map.html',
        controller: 'MapController'

And in your index.html:

<script src=""></script>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download