I’m looking through the code right now. I am taking a GUESS here, but I think the problem is your lack of “dot notation”.
Ionic quite frequently creates child scopes or isolate scopes. So primitives in your controller will not get 2 way binding.
Try the following :
.controller('LoginCtrl', ['$scope', 'loginService', '$location', function($scope, loginService, $location) {
$scope.data = {
"email" : null,
"pass" : null,
"confirm" : null,
"createMode" : false
}
$scope.login = function(cb) {
$scope.err = null;
if( !$scope.data.email ) {
$scope.err = 'Please enter an email address';
}
else if( !$scope.data.pass ) {
$scope.err = 'Please enter a password';
}
else {
loginService.login($scope.data.email, $scope.data.pass, function(err, user) {
$scope.err = err? err + '' : null;
if( !err ) {
cb && cb(user);
}
});
}
};
and
email
<label class="item item-input item-stacked-label">
<span class="input-label">password</span>
<input type="password" placeholder="embody strength" ng-model="data.pass" />
</label>
<label class="item item-input item-stacked-label" ng-show="createMode">
<span class="input-label">confirm pass</span>
<input type="password" placeholder="embody strength" ng-model="data.confirm" />
</label>
<div class="row">
<div class="col col-50">
<button class="button button-block button-positive" ng-click="login()" ng-hide="createMode">Log In</button>
</div> <!-- end .col-50 -->
<div class="col col-50">
<button class="button button-block button-calm" ng-click="createMode = true" ng-hide="createMode">Register</button>
</div> <!-- end .col-50 -->
</div> <!-- end .row -->
<div class="row">
<div class="col col-50">
<button class="button button-block button-calm" ng-show="createMode" ng-click="createAccount()">Create Account</button>
</div> <!-- end .col-50 -->
<div class="col col-50">
<button class="button button-block button-assertive" ng-show="createMode" ng-click="createMode = false">Cancel</button>
</div> <!-- end .col-50 -->
</div> <!-- end .row -->
<div class="row">
<div class="col">
<p ng-show="err" class="assertive text-center">{{err}}</p>
</div> <!-- end .col -->
</div> <!-- end .row -->
</form>
</div> <!-- end .list -->
</ion-content>
<!-- WORKING OUTSIDE OF IONIC
<form>
<label>
<span>email</span>
<input type="text" ng-model="data.email" />
</label>
<label>
<span>password</span>
<input type="password" ng-model="data.pass" />
</label>
<label ng-cloak ng-show="data.createMode">
<span>confirm pass</span>
<input type="password" ng-model="data.confirm" />
</label>
<button ng-click="login()" ng-hide="data.createMode">Log In</button>
<button ng-click="data.createMode = true" ng-hide="createMode">Register</button>
<button ng-cloak ng-show="data.createMode" ng-click="createAccount()">Create Account</button>
<button ng-cloak ng-show="data.createMode" ng-click="data.createMode = false">Cancel</button>
<p ng-show="err" class="error">{{err}}</p>
</form>
-->