"Fossies" - the Fresh Open Source Software Archive

Member "angular.js-1.8.3/DEVELOPERS.md" (7 Apr 2022, 20920 Bytes) of package /linux/www/angular.js-1.8.3.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field. See also the last Fossies "Diffs" side-by-side code changes report for "DEVELOPERS.md": 1.7.9_vs_1.8.0.

Developing AngularJS

Development Setup

This document describes how to set up your development environment to build and test AngularJS, and explains the basic mechanics of using git, node, yarn and grunt.

Installing Dependencies

Before you can build AngularJS, you must install and configure the following dependencies on your machine:

Forking AngularJS on Github

To contribute code to AngularJS, you must have a GitHub account so you can push code to your own fork of AngularJS and open Pull Requests in the GitHub Repository.

To create a Github account, follow the instructions here. Afterwards, go ahead and fork the main AngularJS repository.

Building AngularJS

To build AngularJS, you clone the source code repository and use Grunt to generate the non-minified and minified AngularJS files:

# Clone your Github repository:
git clone https://github.com/<github username>/angular.js.git

# Go to the AngularJS directory:
cd angular.js

# Add the main AngularJS repository as an upstream remote to your repository:
git remote add upstream "https://github.com/angular/angular.js.git"

# Install JavaScript dependencies:
yarn install

# Build AngularJS:
yarn grunt package

Note: If you're using Windows, you must use an elevated command prompt (right click, run as Administrator). This is because yarn grunt package creates some symbolic links.

The build output is in the build directory. It consists of the following files and directories:

Running a Local Development Web Server

To debug code, run end-to-end tests, and serve the docs, it is often useful to have a local HTTP server. For this purpose, we have made available a local web server based on Node.js.

  1. To start the web server, run:

    yarn grunt webserver
  2. To access the local server, enter the following URL into your web browser:


    By default, it serves the contents of the AngularJS project directory.

  3. To access the locally served docs, visit this URL:


Running Tests

Running the Unit Test Suite

We write unit and integration tests with Jasmine and execute them with Karma. To run all of the tests once on Chrome run:

yarn grunt test:unit

To run the tests on other browsers use the command line flag:

yarn grunt test:unit --browsers=Chrome,Firefox

Note: there should be no spaces between browsers. Chrome, Firefox is INVALID.

If you have a Saucelabs or Browserstack account, you can also run the unit tests on these services via our pre-defined customLaunchers. See the karma config file for all pre-configured browsers.

For example, to run the whole unit test suite on selected browsers:

# Browserstack
yarn grunt test:unit --browsers=BS_Chrome,BS_Firefox,BS_Safari,BS_IE_9,BS_IE_10,BS_IE_11,BS_EDGE,BS_iOS_10
# Saucelabs
yarn grunt test:unit --browsers=SL_Chrome,SL_Firefox,SL_Safari,SL_IE_9,SL_IE_10,SL_IE_11,SL_EDGE,SL_iOS_10

Running these commands requires you to set up Karma Browserstack or Karma-Saucelabs, respectively.

During development, however, it's more productive to continuously run unit tests every time the source or test files change. To execute tests in this mode run:

  1. To start the Karma server, capture Chrome browser and run unit tests, run:

    yarn grunt autotest
  2. To capture more browsers, open this URL in the desired browser (URL might be different if you have multiple instance of Karma running, read Karma's console output for the correct URL):

  3. To re-run tests just change any source or test file.

To learn more about all of the preconfigured Grunt tasks run:

yarn grunt --help

Running the End-to-end Test Suite

AngularJS's end to end tests are run with Protractor. Simply run:

yarn grunt test:e2e

This will start the webserver and run the tests on Chrome.

Coding Rules

To ensure consistency throughout the source code, keep these rules in mind as you are working:

Specific topics

Provider configuration

When adding configuration (options) to providers, we follow a special pattern.

For a boolean config example, see $compileProvider#debugInfoEnabled

For an object config example, see $location.html5Mode

Throwing errors

User-facing errors should be thrown with minErr, a special error function that provides errors ids, templated error messages, and adds a link to a detailed error description.

The $compile:badrestrict error is a good example for a well-defined minErr: code and description.

Git Commit Guidelines

We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate the AngularJS change log.

The commit message formatting can be added using a typical git workflow or through the use of a CLI wizard (Commitizen). To use the wizard, run yarn run commit in your terminal after staging your changes in git.

Commit Message Format

Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject:

<type>(<scope>): <subject>

The header is mandatory and the scope of the header is optional.

Any line of the commit message cannot be longer than 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools.


If the commit reverts a previous commit, it should begin with revert: , followed by the header of the reverted commit. In the body it should say: This reverts commit <hash>., where the hash is the SHA of the commit being reverted.


Must be one of the following:


The scope could be anything specifying place of the commit change. For example $location, $browser, $compile, $rootScope, ngHref, ngClick, ngView, etc...

You can use * when the change affects more than a single scope.


The subject contains succinct description of the change:


Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.

The footer should contain any information about Breaking Changes and is also the place to reference GitHub issues that this commit closes.

Breaking Changes should start with the word BREAKING CHANGE: with a space or two newlines. The rest of the commit message is then used for this.

A detailed explanation can be found in this document.

Writing Documentation

The AngularJS project uses a form of jsdoc called ngdoc for all of its code documentation.

This means that all the docs are stored inline in the source code and so are kept in sync as it changes.

There is also extra content (the developer guide, error pages, the tutorial, and misceallenous pages) that live inside the AngularJS repository as markdown files.

This means that since we generate the documentation from the source code, we can easily provide version-specific documentation by simply checking out a version of AngularJS and running the build.

Extracting the source code documentation, processing and building the docs is handled by the documentation generation tool Dgeni.

Building and viewing the docs locally

The docs can be built from scratch using grunt:

yarn grunt docs

This defers the doc-building task to gulp.

Note that the docs app is using the local build files to run. This means you might first have to run the build:

yarn grunt build

(This is also necessary if you are making changes to minErrors).

To view the docs, see Running a Local Development Web Server.

Writing jsdoc

The ngdoc utility has basic support for many of the standard jsdoc directives. But in particular it is interested in the following block tags:

The type in @param and @returns must be wrapped in {} curly braces, e.g. {Object|Array}. Parameters can be made optional by either appending a = to the type, e.g. {Object=}, or by putting the [name] in square brackets. Default values are only possible with the second syntax by appending =<value> to the parameter name, e.g. @param {boolean} [ownPropsOnly=false].

Descriptions can contain markdown formatting.

AngularJS-specific jsdoc directives

In addition to the standard jsdoc tags, there are a number that are specific to the Angular code-base:

The following are specific to directives:

The @ngdoc Directive

This directive helps to specify the template used to render the item being documented. For instance, a directive would have different properties to a filter and so would be documented differently. The commonly used types are:

General documentation with Markdown

Any text in tags can contain markdown syntax for formatting. Generally, you can use any markdown feature.


Only use h2 headings and lower, as the page title is set in h1. Also make sure you follow the heading hierarchy. This ensures correct table of contents are created.

Code blocks

In line code can be specified by enclosing the code in back-ticks (`). A block of multi-line code can be enclosed in triple back-ticks (```) but it is formatted better if it is enclosed in <pre>...</pre> tags and the code lines themselves are indented.

Writing runnable (live) examples and e2e tests

It is possible to embed examples in the documentation along with appropriate e2e tests. These examples and scenarios will be converted to runnable code within the documentation. So it is important that they work correctly. To ensure this, all these e2e scenarios are run as part of the continuous integration tests.

If you are adding an example with an e2e test, you should run the test locally first to ensure it passes. You can change it(...) to fit(...) to run only your test, but make sure you change it back to it(...) before committing.

The <example> tag

This tag identifies a block of HTML that will define a runnable example. It can take the following attributes:

Within this tag we provide <file> tags that specify what files contain the example code.

  <file name="index.html">...</file>
  <file name="script.js">...</file>
  <file name="animations.css">...</file>
  <file name="protractor.js">...</file>

You can see an example of a well-defined example in the ngRepeat documentation.