In the block that is filled with ng-repeat there is a block

<div class="col-xs-12 col-md-12 main-block-history" ng-repeat="order in orders"> <div class="row block-history-footer"> <div class="col-xs-12 col-md-6 action-accordion-history"> <a>Развернуть</a> </div> </div> <div class="row block-history-body" style="display: none; opacity: 0;"> </div> </div> 

After that, a post request is sent to the controller and the $ scope.orders variable is populated and the content of the block is filled accordingly, but the events are not tied to the blocks with the action-accordion-history class.

 var app = angular.module('BlankApp', ['ngMaterial']); app.controller('BlankAppController', function ($scope, $http) { $http({ url: "dirService", method: "post", headers: { "Content-Type": "application/json; charset=utf-8", "dataType": "json" }, data: "{ 'token': '" + getCookie("token") + "' }" }).then(function (response) { $scope.orders = response.data.d; $('.action-accordion-history').on('click'); }); }); $(function () { $(".action-accordion-history").click(function () { var block = $(this).parent().parent().find(".block-history-body"); if (!block.is(":visible")) { block.show(); block.stop().animate({ opacity: 1 }, 150); $(this).html("<a>Свернуть</a>"); } else { block.stop().animate({ opacity: 0 }, 150, function () { block.hide(); }); $(this).html("<a>Развернуть</a>"); } }); }); 

How to be. How to bind the click event to the created blocks with the action-accordion-history class? The problem is that if an event is created with the help of ng-click on the controller, that the function must be passed a link to the controller on which event the event occurred, but I did not find how to do it.

  • it's worth deciding whether you use angular or jquery - Grundy
  • instead of using jquery, you just had to add ng-click to the desired element - Grundy
  • But after all, in ng-click you need to pass a link to the element in order to roll back to the block. Var block = $ (this) .parent (). Parent (). Find (". Block-history-body"); But passing the ng-click = "clickBlock (this)" function honestly, I don’t know what is being accepted, but this is definitely not the object that was clicked on. Here I admit, I could not figure it out, my knowledge of JS is at a novice level and a small amount of practice. - Max ProstoMax
  • There is no need for knowledge of js, here you need to read the help of the angular. The main problem is that instead of the standard tools a crutch is written on jquery - Grundy
  • Maybe share your experience? I understand the event on the click of the controller should be created in the controller, but the question is how in the function to click a link to the object you clicked on, so that you can roll back two parents from this controller and find another control in this block and show it? as written in the code. - Max ProstoMax

0