1.2.4 • Published 4 years ago

angular-stats v1.2.4

Weekly downloads
5
License
-
Repository
github
Last release
4 years ago

Angular Stats

This is a lightweight utility that gives you some statistics about your angularjs application. In particular, you get the

  1. number of scopes,
  2. number of watchers,
  3. number of DOM elements,
  4. duration of digest cycles,

For every angularjs component where you define the property name, you get also

  1. Number of watchers per component.

The property name can be defined on your controller class or binded to the scope. The module has been developed usign Typescript and is exported as UMD, so you can use a module resolver (Webpack / Browserify) in order to import it or add it globally.

Requirements

  1. AngularJs 1.5+ (it doesn't require jQuery)

  2. The utility is not working with angular >= 2.x

Installation

npm install angular-stats --save

Build

npm run build

Usage

// --- app.module.ts ---
// Typescript + ES2015 modules

import { angularStats } from "angular-stats";

export const app = angular.module("myApp", [angularStats])
    .component("app", AppComponent)
    .name;


// --- app.component.ts ---
// ...define your AppComponent using an AppController like this: 

import { IAngularStats } from "angular-stats";

export class AppController {
	private document: ng.IDocumentService;
	private angularStats: IAngularStats;
	
	static $inject = ["AngularStats"];

	constructor($document: ng.IDocumentService, 
	            AngularStats: IAngularStats) {
		this.document = $document;
	    this.angularStats = AngularStats;
	    this.name = "AppComponent";
	}
	
	get analysis(): string {
		return "<pre>" + this.angularStats.analyzeWebApp() + "</pre>";
	}

	$onInit() {
	    /**
	    * By default, AngularStats will search for
	     * an element like <app></app>. If you want 
	     * to change it, set a different starting
	     * element (element: JQLite)
        */
	    this.angularStats.setStartingElement(this.document.find("my-element"));
	}
}
// Javascript

angular.module("myApp", ["angular-stats"])
    .controller("AppController", ["$scope", "AngularStats", function($scope, AngularStats) {
        
        this.$onInit = function() {
            $scope.name = "AppComponent";
            /**
            * By default, AngularStats will search for
             * an element like <app></app>. If you want 
             * to change it, set a different starting
             * element (element: JQLite)
            */
            AngularStats.setStartingElement($document.find("my-element"));
        };
        
        $scope.getStats = function() {
            return "<pre>" + AngularStats.analyzeWebApp() + "</pre>";
        };
}]);

If you bundle app and vendors in two different bundles, require the module using angular-stats

1.2.4

4 years ago

1.2.3

5 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.25

7 years ago

1.0.24

7 years ago

1.0.23

7 years ago

1.0.22

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

2.0.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.13.0

7 years ago

0.12.0

7 years ago

0.11.0

7 years ago

0.10.0

7 years ago

0.9.0

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago