Attempting to transfer values from input
elements back to the controller using ng-model
.
Tried assigning email
to the ng-model
, but upon logging it to the console, it showed as undefined
.
Investigated these two resources:
- Why is my ng-model variable undefined in controller?
Even when utilizing the dot notation, no output shows up on the console whatsoever. (not even 'Email: '
)
The only error message received is:
TypeError: Cannot read property 'email' of undefined
HTML:
<ion-view title="Register" hide-nav-bar="true" nav-transition="none" id="page9">
<ion-content padding="true" class="manual-ios-statusbar-padding" scroll="false">
<form id="register-form4" class="list">
<ion-list id="register-list4">
<label class="item item-input" id="register-input7">
<input type="email" ng-model="reg.email" placeholder="Email">
</label>
<label class="item item-input" id="register-input9">
<input type="password" ng-model="reg.password" placeholder="Password">
</label>
</ion-list>
<a ui-sref="tabsController.myTrips" id="register-button7" ng-click="register()" class="button button-positive button-block">Create Account</a>
<a ui-sref="login" id="register-button8" class="button button-positive button-block button-clear">Back</a>
<div ng-show="isError">{{ loginError }}</div>
</form>
</ion-content>
</ion-view>
Controller:
.controller('registerCtrl', ['$scope', '$stateParams', "$firebaseAuth",
function ($scope, $stateParams, $firebaseAuth) {
$scope.register = function() {
var email = $scope.reg.email,
password = $scope.reg.password;
console.log("Email: " + email);
console.log("Password: " + password);
// ...
}
}])
Additionally, experimented with changing the HTML input type (from email
to text
) but the same error persists.