M
M
Maxim Ivanov2016-07-12 15:25:24
Angular
Maxim Ivanov, 2016-07-12 15:25:24

What causes an error when clicking on a dom element (AngularJS)?

a68ae83a39214218bc8012411dece603.png6136a6836a4e4fda9cbe4ee81db63638.png
When I click on the button, I need the text of this button to appear in another place, 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>

// когда кликаем по кнопке
 $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();


}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2016-07-12
@splincodewd

ng-click so calls $digest loop, $scope.$apply() is optional

M
Maxim Ivanov, 2016-07-12
@splincodewd

pancake, stupidly it is necessary to remove $scope.$apply();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question