Home Web Front-end JS Tutorial Issues related to listening to ng-repeat rendering in AngularJS

Issues related to listening to ng-repeat rendering in AngularJS

Jun 11, 2018 pm 05:00 PM
angularjs rendering monitor

This article mainly introduces two methods for AngularJS to monitor the completion of ng-repeat rendering, and analyzes the related operating techniques of AngularJS based on custom instructions and broadcast events to implement the monitoring function based on examples. Friends in need can refer to the following

The examples in this article describe two methods for AngularJS to monitor the completion of ng-repeat rendering. Share it with everyone for your reference, the details are as follows:

There are two methods to monitor the completion of ng-repeat rendering

1. The most practical method:

<ul class="pprt_content">
    <li ng-repeat="src in imageHotList track by $index" ng-click=&#39;goGoodsDet(src.goodsId,src.merchId)&#39; on-finish-render-filters="completeRepeat">
      <img ng-src="{{productUrl}}{{src.imageName}}">
    </li>
</ul>
Copy after login

Corresponding scope controller:

$scope.completeRepeate= function(){
alert(&#39;1&#39;)
}
Copy after login

Custom instruction directive:

var app = angular.moduler(&#39;myApp&#39;,[]);
app.directive(&#39;onFinishRenderFilters&#39;, [&#39;$timeout&#39;, function ($timeout) {
    return {
      restrict: &#39;A&#39;,
      link: function(scope,element,attr) {
        if (scope.$last === true) {
          var finishFunc=scope.$parent[attr.onFinishRenderFilters];
          if(finishFunc)
          {
            finishFunc();
          }
        }
      }
    };
}])
Copy after login

2. Use broadcast events

/*
* Controller文件中的代码
* Setup general page controller
*/
MetronicApp.controller(&#39;simpleManageController&#39;, [&#39;$rootScope&#39;,
&#39;$scope&#39;, &#39;settings&#39;,&#39;$http&#39;, function($rootScope, $scope, settings,$http) {
  $scope.$on(&#39;ngRepeatFinished&#39;, function (ngRepeatFinishedEvent) {
    //下面是在table render完成后执行的js
    FormEditable.init();
    Metronic.stopPageLoading();
    $(".simpleTab").show();
  });
});
MetronicApp.directive(&#39;onFinishRenderFilters&#39;, function ($timeout) {
  return {
    restrict: &#39;A&#39;,
    link: function(scope,element,attr) {
      if (scope.$last === true) {
        $timeout(function() {
          scope.$emit(&#39;ngRepeatFinished&#39;);
        });
      }
    }
  };
});
Copy after login

HTML

<!--HTML页面的代码,添加标签onFinishRenderFilters(格式有变):on-finish-render-filters-->
 <tr style="display: none" class="simpleTab" ng-repeat="simpleProduct in simpleProducts"
   on-finish-render-filters>
     <td>
       {{simpleProduct.productNo}}
     </td>
</tr>
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to use the global prompt box component in vue?

How to use ElementRef application in Angular4

How to use cli request proxy and project packaging issues in vue

Use webpack template in vue-cli to solve project construction and packaging path problems

Bus global event center in vue (detailed tutorial)

The above is the detailed content of Issues related to listening to ng-repeat rendering in AngularJS. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to render orthogonal top view in Kujiale_Tutorial on rendering orthogonal top view in Kujiale How to render orthogonal top view in Kujiale_Tutorial on rendering orthogonal top view in Kujiale Apr 02, 2024 pm 01:10 PM

1. First open the design plan to be rendered in Kujiale. 2. Then open top view rendering under the rendering menu. 3. Then click Orthogonal in the parameter settings in the top view rendering interface. 4. Finally, after adjusting the model angle, click Render Now to render the orthogonal top view.

Is vue page rendering synchronous or asynchronous? Is vue page rendering synchronous or asynchronous? Dec 13, 2022 pm 07:26 PM

Vue page rendering is asynchronous. Vue uses asynchronous rendering, which can improve performance; if asynchronous updates are not used, the current component will be re-rendered every time the data is updated. For performance reasons, Vue will asynchronously update the view after this round of data updates.

Monitor iframe scrolling behavior Monitor iframe scrolling behavior Feb 18, 2024 pm 08:40 PM

How to monitor the scrolling of an iframe requires specific code examples. When we use the iframe tag to embed other web pages in a web page, sometimes we need to perform some specific operations on the content in the iframe. One of the common needs is to listen for the scroll event of the iframe so that the corresponding code can be executed when the scroll occurs. The following will introduce how to use JavaScript to monitor the scrolling of an iframe, and provide specific code examples for reference. Get the iframe element First, we need

Vue error: v-html cannot be used correctly to render dynamic HTML code. How to solve it? Vue error: v-html cannot be used correctly to render dynamic HTML code. How to solve it? Aug 19, 2023 pm 12:27 PM

Vue error: v-html cannot be used correctly to render dynamic HTML code. How to solve it? Introduction: In Vue development, we often need to dynamically render HTML code to display rich text content or dynamically generated user input. Vue provides the v-html directive to implement this function. However, sometimes we may encounter problems that cannot correctly render dynamic HTML code using v-html. This article will explore the causes of this problem and provide solutions. Problem description: In Vue, when we use v

The latest 5 angularjs tutorials in 2022, from entry to mastery The latest 5 angularjs tutorials in 2022, from entry to mastery Jun 15, 2017 pm 05:50 PM

Javascript is a very unique language. It is unique in terms of the organization of the code, the programming paradigm of the code, and the object-oriented theory. The issue of whether Javascript is an object-oriented language that has been debated for a long time has obviously been There is an answer. However, even though Javascript has been dominant for twenty years, if you want to understand popular frameworks such as jQuery, Angularjs, and even React, just watch the "Black Horse Cloud Classroom JavaScript Advanced Framework Design Video Tutorial".

Vue error: Unable to correctly use v-html to render HTML code, how to solve it? Vue error: Unable to correctly use v-html to render HTML code, how to solve it? Aug 26, 2023 am 11:25 AM

Vue error: Unable to correctly use v-html to render HTML code, how to solve it? Vue is a popular JavaScript framework that can help us build interactive user interfaces. In Vue, we can use the v-html directive to render HTML code into templates. However, sometimes we may encounter a problem: the HTML code cannot be rendered correctly using v-html. This article will describe some common causes and solutions to help you solve this problem. The first possible reason is that the

Use PHP and AngularJS to build a responsive website to provide a high-quality user experience Use PHP and AngularJS to build a responsive website to provide a high-quality user experience Jun 27, 2023 pm 07:37 PM

In today's information age, websites have become an important tool for people to obtain information and communicate. A responsive website can adapt to various devices and provide users with a high-quality experience, which has become a hot spot in modern website development. This article will introduce how to use PHP and AngularJS to build a responsive website to provide a high-quality user experience. Introduction to PHP PHP is an open source server-side programming language ideal for web development. PHP has many advantages, such as easy to learn, cross-platform, rich tool library, development efficiency

v-for function in Vue3: perfect solution to list data rendering v-for function in Vue3: perfect solution to list data rendering Jun 19, 2023 am 08:04 AM

In Vue3, v-for is considered the best way to render list data. v-for is a directive in Vue that allows developers to iterate through an array or object and generate a piece of HTML code for each item. The v-for directive is one of the most powerful template directives available to developers. In Vue3, the v-for instruction has been further optimized, making it easier to use and more flexible. The biggest change of the v-for directive in Vue3 is the binding of elements. In Vue2, use the v-for directive

See all articles