For some reason, I cannot get the state to change when I make a login $http post to my local server.
Controller:
$scope.login = function(user){
$http.post('/api/v1/user/login', user)
.success(function(data, status){
console.log(data);
authToken.setToken(data);
$state.go('user.exercises');
})
.error(function(data, status){
$scope.status = data;
});
};
HTML:
<div class="list">
<label class="item item-input">
<span class="input-label">Username</span>
<input type="text" ng-model="user.username">
</label>
<label class="item item-input">
<span class="input-label">Password</span>
<input type="password" ng-model="user.password">
</label>
</div>
<div class="padding">
<button class="button button-block button-positive" ng-click="login(user)">
Log In
</button>
<p class="text-center">
<a href="#/forgot-password">Forgot password</a>
</p>
</div>
ionic.project:
"proxies": [
{
"path": "/api/v1",
"proxyUrl": "http://localhost:5000/api/v1"
}
]
config.xml
<description>
An Ionic Framework and Cordova project.
</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">
Ionic Framework Team
</author>
<content src="index.html"/>
//important
<access origin="*"/>
<allow-navigation href="http://*/*" />
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
I'm not sure if it has to do with the way I have it set up to use my server or if it is an actually ionic and ui-router problem. This works with my web version.
UPDATE:
It works if there are two $state.gos. Not one or the other. It needs to have both. This doesn't make any sense.
$scope.login = function(user){
$state.go('user.exercises');
$http.post('/api/v1/user/login', user)
.success(function(data, status){
console.log(data);
authToken.setToken(data);
$state.go('user.exercises');
})
.error(function(data, status){
console.log(data);
$scope.status = data;
});
};