enter image description here enter image description here When I click on a button, I need the text of this button to appear elsewhere, but a constant error is displayed.

<div class="col-content"> <div class="blc title">{{ title.proccess }}</div> <span class="blc" ng-repeat="process in processess" ng-click="processCreate($event, process)" data-id="{{ process.id }}" data-enable="false"> <i class="fa fa-dot-circle-o"></i> <span class="p-left" >{{ process.caption }}</span> </span> </div> <div class="col-content"> <div class="blc maintitle">{{ title.namecontent }}</div> </div> 

enter the image description here, enter the image description here. When I click on the button, I need the text of this button to appear in another place, but a constant error is displayed.

  // когда кликаем по кнопке $scope.processCreate = function(event, process){ var id = process.id; var caption = process.caption; $('[data-id]').removeClass('active'); $('[data-id=' + id+']').addClass('active'); $scope.title.namecontent = caption; $scope.$apply(); } 
  • pancake, it is stupid to remove $ scope. $ apply (); - splincode
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Grundy

1 answer 1

Error due to use of $apply inside handler function.

Any user interaction starts the digest loop and when trying to start it again, with $apply ends with the specified error

you should decide to use an angular or jQuery, if you need to add a class to remove, it’s better to use the ng-class directive