2016-10-04 60 views
0
<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> 

这是我的列表。需要在添加注释,然后按更新输入:更新js文件中的列表后,我的UI没有更新

<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); 
}; 

我m如果在警告增加了长度,但是在UI没有反映。

+0

可以添加小提琴/ plunkr ...? – Aks1357

回答

0

您需要手动调用观察者的角度使用:

$scope.$apply()