Coder Social home page Coder Social logo

ng-perf's Introduction

ng-perf is a set of utilities to help with AngularJS performance.

ngp-local-*

A set of events that invoke $scope.digest() instead of $rootScope.apply. This will help with directives where the result of events only needs to be applied to the current scope and downward instead of all the way from rootScope. These events also provide a way to supress the digest altogether via preventDefault method.

To use directives

	bower install ng-perf

Include ngPerfLocalDirectives.js and add module ngPerf.directives as a dependency

Here's an example directive using ngp-local-click.

angular.module('ngPerf.randomButton', ['ngPerf.directives'])
    .directive('randomButton', function() {
        return {
            restrict: 'EA',
            scope: {},
            controller: function($scope) {
                $scope.randomNumber = '123';
                $scope.generateRandom = function() {
                    $scope.randomNumber = Math.floor(Math.random()*100);
//                    event.preventDefault(); //uncomment to suppress digest altogether
                }
            },
            template: '<button ngp-local-click="generateRandom(event)">Random</button><span ng-bind="randomNumber"></span>',
            link: function(){}
        };
    });

ng-perf's People

Contributors

ansukla avatar

Watchers

Rui Araújo avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.