**html file**
<body ng-app="starter">
<ion-pane>
<ion-header-bar class="bar-stable">
<div ng-controller="loginCtrl">
<h3>Login</h3>
<form>
<label>Username:</label><input type="text" ng-model="username" /><br><br>
<label>Password:</label><input type="password" ng-model="password"><br>
<button type="submit" ng-click="submit()">login</button>
</form>
</div>
</ion-header-bar>
<ion-content>
</ion-content>
</ion-pane>
<script type="text/javascript">
var app = angular.module('starter', ['ionic']);
app.controller('loginCtrl', function($scope, $location, $http, $state){
$scope.submit=function()
{
var user=$scope.username;
var pass=$scope.password;
if($scope.username=="admin" && $scope.password=="1234")
{
$location.path('templates/first');
}
else
{
/alert("error");/
$location.path('/second');
}
}
});
location.path is correct syntax to navigate the page but it is working in the url bar but not the page navigation.
**app.js file**
angular.module('starter', ['ionic'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('/', {
url: '/',
abstract: true,
templateUrl: 'index.html'
})
.state('/first', {
url: '/first',
abstract: true,
templateUrl: 'templates/first.html'
})
.state('/second', {
url: '/second',
abstract: true,
templateUrl: 'templates/second.html'(these first and second html pages are given in templates folder in www folder of the project.
});
$urlRouterProvider.otherwise({ redirectTo: '/login' });
});
the page is not navigating to first.html page after clicking submit button.