i just wana get my input value in controller. But i always got an 'undefined' in web page.
This is my HTML code.
<div class="list">
<label class="item item-input">
<input id="FirstName" type="text" placeholder="* First Name" data-ng-model="Info.FirstName" />
</label>
</div>
And javascript.
$scope.Info = {};
$scope.Next = function () {
switch (pageno) {
case 1:
alert($scope.Info.FirstName);
break;
case 2:
alert($scope.Info.FirstName);
break;
};
}
when I click the button Next() will run and alert 'undefined'. It's a very simple function. I think is because I use ionic framework.
Are you trying to achieve this ??
HTML
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.3.x" src="https://code.angularjs.org/1.3.15/angular.js" data-semver="1.3.15"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<div class="list">
<label class="item item-input">
<input id="FirstName" type="text" placeholder="* First Name" ng-model="Info.FirstName" />
</label>
<button ng-click="Next(Info)"> Next </button>
{{value}}
</div>
</body>
</html>
Controller
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.Next = function (infodata) {
$scope.value=infodata;
};
});