I'm encountering an issue where the text field input in my view is not binding to the controller.
Below is the snippet from the view:
<md-dialog-content ng-if="mode=='addSentence'" class="sticky-container">
<md-input-container>
<label for="sentence-text">Enter the sentence to be corrected</label>
<input ng-model="theSentence" name="sentence-text"/>
</md-input-container>
<span flex>{{ error }}</span>
<md-button class="primary" style="float:right;" aria-label="Save" ng-click="saveNewSentence()">Save</md-button>
</md-dialog-content>
And here's the related function in the controller:
function ViewSentenceController($scope, $rootScope, $mdDialog) {
$scope.mode = mode;
$scope.user = user;
$scope.theSentence = null;
$scope.saveNewSentence = function() {
console.log($scope.theSentence);
}
$scope.cancel = function() { $mdDialog.hide(); }
}
After invoking saveNewSentence()
, it consistently logs a value of null
to the console, even when there is input in the textfield.
I feel like I must be overlooking something simple, as I've spent an excessive amount of time on this seemingly straightforward issue. Any help would be greatly appreciated!