新行添加ng-repeat其他函数

时间:2017-04-10 04:52:04

标签: angularjs

我正在使用ng-repeat我的要求是新行输入ng重复其他功能自动运行。



<span ng-repeat="sal in studentAttendanceList">
              {{sal.name}}       {{sal.class}}        {{sal.rolenumber}}
</span>
&#13;
&#13;
&#13;

controller.js

&#13;
&#13;
var studentList = Firebase.get('studentAttendanceList', 'name', $stateParams.chatId);
studentList.$loaded().then(function() {
  $ionicScrollDelegate.scrollBottom(true);
  $scope.studentAttendanceList = studentList;
});
$scope.studentAttendanceListalert = function() {
  alert(add new enter);
}
&#13;
&#13;
&#13;

如果添加新的输入警报出现。它是如何在angularjs中工作的。

2 个答案:

答案 0 :(得分:2)

如果您想在每次添加新行时显示警报,请使用watch监控更改

$scope.$wacth('studentAttendanceList',function(oldVal,newVal){
 if($scope.studentAttendanceList && $scope.studentAttendanceList.lenght > 0){
   if(newVal.length > oldVal.length){
    alert("new row added ")
   }
 }
})

答案 1 :(得分:2)

$scope.$watchCollection('studentAttendanceList',function(oldVal,newVal){
if($scope.studentAttendanceList && $scope.studentAttendanceList.lenght > 0){if(newVal.length > oldVal.length){ alert("new row added ")}}})