문제는 제가보기에 텍스트 필드 입력이 컨트롤러에 바인딩되지 않는다는 것입니다. 여기 각도 JS 데이터가 뷰에서 모델로 바인딩되지 않습니다.
뷰 조각입니다 :<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>
그리고 여기에 입력 처리하도록되어 컨트롤러 기능입니다 : 경우에도, saveNewSentence()
는 콘솔에 null
를 기록 호출 될 때
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(); }
}
를 I 텍스트 필드에 입력이 있어야합니다.
나는 뭔가를 놓친 것 같아 보이지 않지만이 간단한 문제에 너무 많은 시간을 썼다. 그래서 도와 주셔서 미리 감사드립니다!
부모가 아닌 대화 상자 내에서 데이터를 바인딩하려고합니다. – Yakuman
여기서 전체 컨트롤러를 볼 수 있습니다 : https://jsfiddle.net/cw797a3b/ – Yakuman