I'm using the Ionic framework which uses AngularJS and I can't access my input field "groupName" in my controller, I just get "undefined".
I thought using ng-model would inject it in the scope of my controller?
<ion-pane>
<ion-header-bar align-title="left" class="bar-positive">
<div class="buttons">
<button class="button" ng-click="saveNewGroup()">Save</button>
</div>
</ion-header-bar>
<ion-content>
<div class="list">
<label class="item item-input">
<input type="text" placeholder="Name" ng-model="groupName">
</label>
</div>
</ion-content>
And the code in my controller:
$scope.saveNewGroup = function() {
console.log($scope.groupName); // prints "undefined" all the time
};
It seems like you didn't define it in your controller so you are trying to access an undefined variable. Define it, and apply the correct controller to the model and you will find it data-binding properly.
Cheers.
EDIT: Glad it worked.