<td rowspan="5" colspan="2">
<div id="style-2" class="scrollit">
<table class="table-borderless table-condensed" style="height:100px; width:100%; overflow-y:scroll">
<tr>
<td colspan="2" class="verticleAlignMidle">
<h6><b>{{ctrl.commentsBox.length}} Comments:</b></h6>
</td>
</tr>
<tr ng-repeat="item in ctrl.commentsBox">
<td class="width8">
<div class="commentCol divStyle">{{item.name}}</div>
</td>
<td class="width11">
<span><b>{{item.FullName}}</b> {{item.date}}</span>
<br /> <span>{{item.comment}}</span>
</td>
</tr>
</table>
</div>
</td>
这是我的清单。需要在添加评论并按Enter键时更新:
<td class="width33 verticleAlignMidle" colspan="2">
<textarea cols="80" rows="5" ng-keyup="$event.keyCode == 13 ? ctrl.saveAdGroup() : null"
ng-model="ctrl.textComment" ng-view="ctrl.textComment" placeholder="Write a comment"></textarea>
</td>
功能是:
ctrl.saveAdGroup = function () {
var ctrl = this;
var c = ctrl.textComment;
ctrl.textComment = "";
var n = "DN";
var fullName = "Dummy Name";
var formatDate = ctrl.dates();
var objComment = { name: n, date: formatDate, comment: c, FullName: fullName };
ctrl.commentsBox.push(objComment);
alert(ctrl.commentsBox.length);
};
我在警报中增加了长度但没有反映在ui中。
答案 0 :(得分:0)
您需要使用以下方法手动调用角度观察器:
$scope.$apply()