<!DOCTYPE html>
<html ng-app="starter">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" type="text/css" href="http://code.ionicframework.com/1.0.0-beta.11/css/ionic.min.css">
<script src="http://code.ionicframework.com/1.0.0-beta.11/js/ionic.bundle.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-controller='MyCtrl'>
<ion-content>
<div class="list">
<label class="item item-input">
<input type="email" placeholder="Enter Email" ng-model="user.email">
</label>
<label class="item item-input">
<input type="email" placeholder="Enter Password" ng-model="user.password">
</label>
{{user.email}}
{{user.password}}
<button class="button button-block button-positive" ng-click="login(user.email,user.password)">Log in</button>
</div>
</ion-content>
</body>
</html>
angular.module('starter', ['ionic'])
.controller('MyCtrl', function($scope) {
$scope.user = {
email: '',
password: ''
}
$scope.login = function(email,password) {
console.log("email is: ",email); // will log undefined
console.log("password is",password); // will log undefined
};
})
/* Styles go here */
### The Issue
I have given `$scope` a property called user which is an object that has an
`email` and a `password`.
`ng-model` doesn't seem to be working because when my login function is called
it is sent in undefiend.
I have tried using `$parent.user.email` but that also didn't work.