我面临一个字符串问题。我已经放置了一个文本输入控件并将其与控制器属性绑定并添加了一个按钮输入,但是当我试图在按钮单击时获取文本输入值时,我变得空白。
控制器
chat.controller('chatController', ['$scope', 'board', '$log', function ($scope, board, $log) {
$scope.Messages = [];
$scope.comment = '';
board.startBoard(function () {
board.loadAllMessages().then(function (messages) {
$scope.Messages = messages;
});
});
$scope.likeClick = function (isfromChild, message) {
$log.info(message);
};
$scope.dislikeClick = function (isfromChild, message) {
$log.info(message);
};
$scope.addComment = function () {
//HERE IS THIS PROBLEM
alert($scope.comment);
$scope.comment = '';
};
} ]);
标记
<div style="margin-top: 10px">
<div class="input-group">
<input type="text" class="form-control" data-ng-model="comment" placeholder="write a comment..." />
<span class="input-group-btn">
<button class="btn btn-info" data-ng-click="addComment()" id="button1">
Post Commant</button></span>
</div>
</div>