### Install AngularJS via Yarn Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/api/module.template.html Example of installing the AngularJS package using Yarn. Replace X.Y.Z with the desired version. ```bash yarn add angular@X.Y.Z ``` -------------------------------- ### Install AngularJS via Bower Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/api/module.template.html Example of installing the AngularJS package using Bower. Replace X.Y.Z with the desired version. ```bash bower install angular#X.Y.Z ``` -------------------------------- ### Render Example File Contents Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/examples/runnableExample.template.html This snippet iterates over the files of a documentation example and renders the content of each file within a code block. It's crucial for displaying runnable code examples. ```html {# Be aware that we need these extra new lines here or marked will not realize that the is HTML and wrap each line in a - thus breaking the HTML #} {% for fileName, file in doc.example.files %} {% code -%} {$ file.fileContents $} {%- endcode %} {% endfor %} {# Be aware that we need these extra new lines here or marked will not realize that the above is HTML and wrap each line in a - thus breaking the HTML #} ``` -------------------------------- ### Install AngularJS via NPM Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/api/module.template.html Example of installing the AngularJS package using NPM. Replace X.Y.Z with the desired version. ```bash npm install --save angular@X.Y.Z ``` -------------------------------- ### Install AngularJS via Google CDN Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/api/module.template.html Example of including the AngularJS library from Google CDN. Replace X.Y.Z with the desired version. ```html "//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular.min.js" ``` -------------------------------- ### Start Firebase Emulators Source: https://github.com/angular/angular.js/blob/master/scripts/docs.angularjs.org-firebase/readme.firebase.docs.md Starts the Firebase emulators for local development. This command serves content from the './deploy' directory and uses local functions. ```bash $(yarn bin)/firebase emulators:start ``` ```bash ..\..\node_modules\.bin\firebase emulators:start ``` -------------------------------- ### Embedding Runnable Examples with Tag Source: https://github.com/angular/angular.js/wiki/Contribution:-Writing-AngularJS-Documentation Use the tag to define a runnable HTML example. Specify the AngularJS module, dependencies, and animation support. Use nested tags for different code files within the example. ```html ... ... ... ... ... ``` -------------------------------- ### Embedding Runnable Examples with Tag Source: https://github.com/angular/angular.js/wiki/Contribution:-Writing-AngularJS-Documentation The tag is another way to define runnable examples. It uses for application code (including script and style tags) and for e2e test code. ```html ... ... ... ... ... ``` -------------------------------- ### AngularJS Service Initialization Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An example showing how to ensure a service's initialization method is called only once on startup in AngularJS. Provided by Pawel Kozlowski. ```javascript http://jsfiddle.net/pkozlowski_opensource/H2ps5/ ``` -------------------------------- ### Input Directive Usage Example Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/api/input.template.html Demonstrates the basic usage of the input directive within an Angular.js template. No specific setup is required beyond including the directive. ```html {% import "lib/macros.html" as lib -%} {% extends "api/directive.template.html" %} {% block usage %}Usage ----- {% code %} {% endcode %} {% endblock %} ``` -------------------------------- ### AngularJS Example Tag Structure Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md This is the basic structure for defining a runnable example within AngularJS documentation. It uses the `` tag with attributes to specify module, name, dependencies, and animations, and includes `` tags for different code components. ```html ... ... ... ... ... ... ``` -------------------------------- ### AngularJS Parse URL Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples A jsFiddle example demonstrating how to parse URLs within an AngularJS application. ```javascript http://jsfiddle.net/PT5BG/4/ ``` -------------------------------- ### AngularJS Basic Transclude Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples A basic example demonstrating the concept of transclusion in AngularJS directives. Provided by Omkar Patil. ```javascript http://jsfiddle.net/ospatil/A969Z/ ``` -------------------------------- ### AngularJS Search and Pagination Combination Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An example demonstrating the combination of search and pagination functionalities within an AngularJS application. This jsFiddle provides a practical implementation. ```javascript http://jsfiddle.net/SAWsA/11/ ``` -------------------------------- ### Define a Service using Factory Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Dependency-Injection Use `$provide.factory` as a shortcut to define a service. It directly returns the service instance, equivalent to the `$get` function of a provider. ```javascript myMod.config(function($provide) { $provide.factory('greeting', function() { return function(name) { alert("Hello, " + name); }; }); }); ``` -------------------------------- ### AngularJS Speech Bubble Example using Transclude Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An example from an AngularJS-DC meetup demonstrating a speech bubble component implemented using transclusion. ```javascript http://jsfiddle.net/angularjsdc/gCPDs/ ``` -------------------------------- ### AngularJS Dropdown Select and Menu Directives Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples A jsFiddle example showcasing custom directives for dropdown select and menu functionalities in AngularJS. Provided by jseppi. ```javascript http://jsfiddle.net/jseppi/cTzun/1/ ``` -------------------------------- ### Baseline Binding Example Source: https://github.com/angular/angular.js/blob/master/benchmarks/largetable-bp/main.html Demonstrates the most basic form of data binding in AngularJS. ```html none: ``` -------------------------------- ### Run Local Development Server Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Start a local Node.js-based web server to debug code, run tests, and serve documentation. Access the server at http://localhost:8000/. ```shell yarn grunt webserver ``` -------------------------------- ### Clone and Build AngularJS Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Clone the repository, set up upstream, install dependencies, and build the project using Grunt. Ensure you are using an elevated command prompt on Windows. ```shell git clone https://github.com//angular.js.git cd angular.js git remote add upstream "https://github.com/angular/angular.js.git" yarn install yarn grunt package ``` -------------------------------- ### AngularJS Media RSS Reader Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An example of a Media RSS reader built with AngularJS that retains scroll position between views. Provided by BkXyQ. ```javascript http://jsfiddle.net/BkXyQ/6/ ``` -------------------------------- ### Define a Service using Provider Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Dependency-Injection Use the `$provide.provider` method in a config function to define a new service. The `$get` function returns the injectable service. ```javascript myMod.config(function($provide) { $provide.provider('greeting', function() { this.$get = function() { return function(name) { alert("Hello, " + name); }; }; }); }); ``` -------------------------------- ### Run Unit Tests on Saucelabs Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Executes the unit test suite on Saucelabs using pre-configured launchers. Requires Karma-Saucelabs setup. ```shell # 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 ``` -------------------------------- ### Compile and Test ng-closure-runner Source: https://github.com/angular/angular.js/blob/master/vendor/ng-closure-runner/README.md Use this command to compile the project and run its tests using Gradle. Ensure you have a compatible JDK installed. ```bash $ gradle check ``` -------------------------------- ### Interactive JavaScript Compilation Example Source: https://github.com/angular/angular.js/blob/master/vendor/closure-compiler/README.md Demonstrates compiling a simple JavaScript expression in the interactive mode of the Closure Compiler. ```javascript var x = 17 + 25; ``` -------------------------------- ### AngularJS Dynamic Form Fields Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples A jsFiddle example demonstrating how to create dynamic form fields within an AngularJS application. This is useful for forms with a variable number of inputs. ```javascript http://jsfiddle.net/buele/nYzjY/ ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Starts the webserver and runs the end-to-end tests on Chrome using Protractor. ```shell yarn grunt test:e2e ``` -------------------------------- ### AngularJS Numeric Input Formatting Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An AngularJS directive example for formatting numeric inputs with decimal marks (commas and points), suitable for currency inputs. Provided by Erick Mendoza. ```javascript http://jsfiddle.net/odiseo/dj6mX/ ``` -------------------------------- ### Isolate Scope Binding Example Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Scopes This example demonstrates how to set up two-way binding ('=') and one-way binding ('@') between a parent scope and an isolate scope using attributes. Note that attributes must be used to specify parent properties for binding. ```html
``` ```javascript scope: { localProp: '@theParentProp' } ``` -------------------------------- ### AngularJS Glossary of Terms (Compile Function) Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An example from an AngularJS-DC meetup showcasing a 'Glossary of Terms' using a compile function within an AngularJS directive. ```javascript http://jsfiddle.net/angularjsdc/KRVSQ/ ``` -------------------------------- ### Run Unit Tests on Browserstack Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Executes the unit test suite on Browserstack using pre-configured launchers. Requires Karma Browserstack setup. ```shell # 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 ``` -------------------------------- ### Get and Use a Service via Injector Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Dependency-Injection Obtain an instance of a service using the `$injector.get()` method. This allows retrieving services outside of the normal injection mechanism. ```javascript var greeting = $injector.get('greeting'); greeting('Ford Prefect'); ``` -------------------------------- ### Continuously Run Unit Tests Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Starts the Karma server and continuously runs unit tests, re-running them whenever source or test files change. ```shell yarn grunt autotest ``` -------------------------------- ### AngularJS Transclude Injection into Controller Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples Demonstrates how to use the '$transclude' injection within an AngularJS controller. Provided by Omkar Patil. ```javascript http://jsfiddle.net/ospatil/A969Z/4/ ``` -------------------------------- ### Include AngularJS via code.angularjs.org Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/api/module.template.html Example of including the AngularJS library from code.angularjs.org. This is discouraged for production use. Replace X.Y.Z with the desired version. ```html "//code.angularjs.org/X.Y.Z/angular.min.js" ``` -------------------------------- ### AngularJS ngAnimate + Animate.css Demo Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An example of integrating ngAnimate with the Animate.css library for easily applying pre-defined CSS animations in AngularJS projects. ```html http://plnkr.co/edit/BuyfEPmQC8FrQYH5Vzas ``` -------------------------------- ### Using $scope.$apply() with $rootScope.$broadcast Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-When-to-use-$scope.$apply() This example demonstrates a valid use case for $scope.$apply() when broadcasting an event. Ensure $scope.$apply() is called as close to the asynchronous event as possible. ```javascript $rootScope.$apply($rootScope.$broadcast('receivedMsg', msg)); ``` -------------------------------- ### AngularJS ngClass + CSS3 Transition Demo Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples Demonstrates the use of ngClass with CSS3 transitions for animations in AngularJS. This example is part of a series exploring animation techniques. ```html http://plnkr.co/edit/kKzXBtXIheVpowtPXlsT ``` -------------------------------- ### Load AngularJS Module in Application Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/api/module.template.html Example of loading an AngularJS module by adding it as a dependent module to your application. Replace 'app' with your application's module name and '{$ doc.name $}' with the module you are loading. ```javascript angular.module('app', ['{$ doc.name $}']); ``` -------------------------------- ### AngularJS TreeView (No jQuery) Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An AngularJS-based TreeView component that does not rely on jQuery. Provided by Jaeha Ahn. ```javascript http://jsfiddle.net/eu81273/8LWUc/29/ ``` -------------------------------- ### AngularJS Transclude in Compile Function Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples Shows how to use the 'transclude' argument within the compile function of an AngularJS directive. Provided by Omkar Patil. ```javascript http://jsfiddle.net/ospatil/A969Z/3/ ``` -------------------------------- ### AngularJS Pluralization with Offsets Demo Source: https://github.com/angular/angular.js/blob/master/i18n/e2e/localeTest_en.html Placeholder for demonstrating pluralization with offsets. This setup is typically used when the count for pluralization is derived from a variable other than the direct item count. ```html Name of person1: Name of person2: ``` -------------------------------- ### AngularJS Date Formatting with MomentJS Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples Demonstrates formatting dates in AngularJS using MomentJS. This is particularly useful for displaying dates received in formats like ASP.NET JSON date format ('/Date(1352055184000)/') in a more readable way. ```javascript http://jsfiddle.net/sumrak/6gYAz/2/ ``` -------------------------------- ### Build and View Docs Locally Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Use this command to build the documentation from scratch. This command defers the doc-building task to Gulp. ```shell yarn grunt docs ``` -------------------------------- ### Display Closure Compiler Help Source: https://github.com/angular/angular.js/blob/master/vendor/closure-compiler/README.md Run this command to view all available options and flags for the Closure Compiler. ```bash java -jar compiler.jar --help ``` -------------------------------- ### AngularJS Text Filters Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples A jsFiddle showcasing various text filtering capabilities in AngularJS. This example is provided by Alan Löffler. ```javascript http://jsfiddle.net/VX5LE/4/ ``` -------------------------------- ### Equivalent Service Definitions Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Dependency-Injection Demonstrates multiple ways to define the same 'greeting' service using provider, factory, service, and value, highlighting their equivalence. ```javascript myMod.provider('greeting', function() { this.$get = function() { return function(name) { alert("Hello, " + name); }; }; }); myMod.factory('greeting', function() { return function(name) { alert("Hello, " + name); }; }); myMod.service('greeting', function() { return function(name) { alert("Hello, " + name); }; }); myMod.value('greeting', function(name) { alert("Hello, " + name); }); ``` -------------------------------- ### View Grunt Help Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Displays all available Grunt tasks and their descriptions. ```shell yarn grunt --help ``` -------------------------------- ### Build Closure Compiler Jar using Ant Source: https://github.com/angular/angular.js/blob/master/vendor/closure-compiler/README.md Use the Ant build tool to create a 'compiler.jar' file from the source tree. ```bash ant jar ``` -------------------------------- ### AngularJS Tree Directive with Nested Scope Inheritance Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An example of a tree directive in AngularJS that features nested scope inheritance. Provided by furf. ```javascript http://jsfiddle.net/furf/EJGHX/19/ ``` -------------------------------- ### AngularJS Custom Functionality for Form Directive Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An example of adding custom functionality to built-in form directives in AngularJS. Provided by Omkar Patil. ```javascript http://jsfiddle.net/ospatil/25Rcf/ ``` -------------------------------- ### AngularJS Text Fitting Directive Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples An example of an AngularJS directive that fits text within the width of an `overflow:hidden` block. Provided by mortimerpa. ```javascript http://jsfiddle.net/mortimerpa/AKXez/ ``` -------------------------------- ### Access Local Server and Docs Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Access the locally served AngularJS project files via http://localhost:8000/ and the documentation at http://localhost:8000/build/docs/. ```text http://localhost:8000/ ``` ```text http://localhost:8000/build/docs/ ``` -------------------------------- ### Build AngularJS Documentation Source: https://github.com/angular/angular.js/wiki/Contribution:-Writing-AngularJS-Documentation Use this grunt command to generate all AngularJS distribution files and documentation. The output can be found in the `/build/docs` directory. ```bash grunt package ``` -------------------------------- ### Define a Service using Value Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Dependency-Injection Use `$provide.value` when the service is a constant value or a function that doesn't need complex instantiation. It directly provides the value. ```javascript myMod.config(function($provide) { $provide.value('greeting', function(name) { alert("Hello, " + name); }); }); ``` -------------------------------- ### Directive with Isolate and Transcluded Scope Source: https://github.com/angular/angular.js/wiki/Understanding-Scopes Example of a directive configuration that includes both an isolate scope and transclusion. ```javascript transclude: true, scope: { interpolatedProp: '@interpolated', twowayBindingProp: '=twowayBinding' } ``` -------------------------------- ### Configuring a Service Provider Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Dependency-Injection Define a service provider with configurable options. Use the provider's methods in a config block to customize the service before it's instantiated. ```javascript myMod.provider('greeting', function() { var text = 'Hello, '; this.setText = function(value) { text = value; }; this.$get = function() { return function(name) { alert(text + name); }; }; }); myMod.config(function(greetingProvider) { greetingProvider.setText("Howdy there, "); }); myMod.run(function(greeting) { greeting('Ford Prefect'); }); ``` -------------------------------- ### Execute Release Script Source: https://github.com/angular/angular.js/blob/master/RELEASE.md Run the release script with specific parameters for dry-run, commit SHA, version number, and version name. Ensure you have the necessary write and publish access to GitHub repositories and npm. ```bash scripts/release/release.sh --git-push-dryrun=false --commit-sha=8822a4f --version-number=1.7.6 --version-name=gravity-manipulation ``` -------------------------------- ### orderBy Function Expression Source: https://github.com/angular/angular.js/blob/master/benchmarks/orderby-bp/main.html Sorts the repeated items using a custom function 'rawProperty' to get the sorting key. ```html ng-repeat="row in ctrl.rows | orderBy:rawProperty('name')" ``` -------------------------------- ### Generate Release Notes with changez Source: https://github.com/angular/angular.js/blob/master/RELEASE.md Use the 'changez' tool to generate a draft of release notes from commit history. Review and manually edit the generated file before moving it to CHANGELOG.md. ```bash node_modules/.bin/changez -o changes.md -v ``` -------------------------------- ### Inject and Use a Service in a Controller Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Dependency-Injection Inject the 'greeting' service into a controller to use its functionality. The service is invoked like a regular function. ```javascript myMod.controller('MainController', function($scope, greeting) { $scope.onClick = function() { greeting('Ford Prefect'); }; }); ``` -------------------------------- ### Run Unit Tests on Multiple Browsers Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Runs the unit tests on specified browsers. Ensure no spaces between browser names. ```shell yarn grunt test:unit --browsers=Chrome,Firefox ``` -------------------------------- ### Run Unit Tests Once Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md Executes the entire unit test suite once on Chrome. For other browsers, use the --browsers flag. ```shell yarn grunt test:unit ``` -------------------------------- ### AngularJS ngClass for Complex Animations Demo Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples Illustrates a more complex animation scenario using ngClass in AngularJS. This is one of several examples showcasing animation capabilities. ```html http://plnkr.co/edit/sEVfAsUxW5yhBr6YTmJL ``` -------------------------------- ### Build Local Files for Docs App Source: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md This command is necessary to build the local files that the documentation application uses to run. It is also required when making changes to minErrors. ```shell yarn grunt build ``` -------------------------------- ### Render ngRepeat with 500 elements (Vanilla JS) Source: https://github.com/angular/angular.js/blob/master/benchmarks/repeat-animate-bp/main.html Baseline test using vanilla JavaScript to render 500 elements without AngularJS animations. ```html {{column.i}} ``` -------------------------------- ### Cache Busting $http and HTML Partials Source: https://github.com/angular/angular.js/wiki/FAQ Intercepts $http GET requests to append a cache-busting version parameter to the URL. Ensure `cacheBustVersion` is defined in your scope. ```javascript myAppModule.config(function($routeProvider, $provide) { $provide.decorator('$http', function($delegate){ var get = $delegate.get; $delegate.get = function(url, config){ url += (url.indexOf('?') !== -1) ? '?' : '&'; url += 'v=' + cacheBustVersion; return get(url, config); }; return $delegate; }); }); ``` -------------------------------- ### AngularJS ngAnimate + jQuery Animation Demo Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples Illustrates how to use ngAnimate in conjunction with jQuery for handling animations within an AngularJS application. This example explores integration possibilities. ```html http://plnkr.co/edit/sk4nxf7wyT4myk4nIScs ``` -------------------------------- ### Run all tests locally Source: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md Before creating a pull request, ensure all tests pass by running the grunt test command. This helps catch issues early. ```shell yarn grunt test ``` -------------------------------- ### AngularJS Tree Directive with NestedSortable jQuery Plugin Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples Demonstrates an AngularJS tree directive integrated with the nestedSortable jQuery plugin for sortable tree structures. Provided by michieljoris. ```javascript http://jsfiddle.net/michieljoris/VmtfR/ ``` -------------------------------- ### Create Distribution Zip for Release Source: https://github.com/angular/angular.js/blob/master/vendor/ng-closure-runner/README.md This command generates a distribution zip file for releasing ng-closure-runner. This is part of the release process managed by the Angular core team. ```bash gradle distZip ``` -------------------------------- ### AngularJS Scope Type Annotation with Closure Compiler Source: https://github.com/angular/angular.js/blob/master/README.closure.md Example of annotating an AngularJS $scope object with a Closure Compiler extern for type checking. This helps prevent renaming of scope properties during advanced compilation. ```javascript /** @type {angular.Scope} */ var scope = $scope; ``` -------------------------------- ### Define Services Directly on Module Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Dependency-Injection Provider methods like `provider`, `factory`, `service`, and `value` can be called directly on the module object for brevity. ```javascript var myMod = angular.module('myModule', []); myMod.provider("greeting", ...); myMod.factory("greeting", ...); myMod.service("greeting", ...); myMod.value("greeting", ...); ``` -------------------------------- ### Run Closure Compiler in Interactive Mode Source: https://github.com/angular/angular.js/blob/master/vendor/closure-compiler/README.md Execute the Closure Compiler from the command line to process JavaScript code interactively. ```bash java -jar build/compiler.jar ``` -------------------------------- ### Transclusion and Isolate Scope Relationship Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Scopes This example assumes a directive with `transclude: true` and an isolate scope. It highlights that the isolate scope is the parent of the transcluded scope, and the `$$nextSibling` property of the isolate scope references the transcluded scope. ```javascript transclude: true ``` -------------------------------- ### Parameter Table Macro Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/lib/macros.html Generates an HTML table for function parameters, including name, type, optional status, description, and default value. It utilizes the `typeList` macro for parameter types. ```html {% macro paramTable(params) %} {%- for param in params -%} {%- if param.optional %} _(optional)_ {%- endif -%} {$ typeList(param.typeList) $} {$ param.description | marked $} {%- if param.defaultValue %} _(default: {$ param.defaultValue $})_ {%- endif -%} {%- endfor -%} {%- endmacro -%} ``` -------------------------------- ### AngularJS Pasting Tabular Data Example Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples This jsFiddle demonstrates the 'angular-paste' functionality, allowing users to paste tabular data (e.g., from Excel) directly into an AngularJS application to update scope variables. It also shows integration with jQuery events. ```javascript http://jsfiddle.net/psu9c/6/ ``` -------------------------------- ### Directive Usage Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/api/directive.template.html This section details how to use the directive as an element, attribute, or CSS class, along with its parameters. ```APIDOC ## Directive Usage ### Description Provides information on how to implement the directive in your HTML. ### Usage as Element * as element: ` ... ` ### Usage as Attribute * as attribute: ` ... ` ### Usage as CSS Class * as CSS class: ` ... ` ### Parameters (Parameters are detailed in a separate section, typically including name, type, and description for each parameter.) ``` -------------------------------- ### AngularJS ngAnimate + CSS3 Transition Demo Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples Shows how to implement animations in AngularJS using the ngAnimate module combined with CSS3 transitions. This is part of a series on AngularJS animations. ```html http://plnkr.co/edit/wJ9vFV79Th45ZZzaqTdx ``` -------------------------------- ### AngularJS ngAnimate + CSS3 Keyframe Animation Demo Source: https://github.com/angular/angular.js/wiki/Resources:-JSFiddle-Examples Demonstrates using ngAnimate with CSS3 keyframe animations for more intricate animation effects in AngularJS applications. ```html http://plnkr.co/edit/QN0McbVD39E4527KaaAV ``` -------------------------------- ### Add Stylesheet Links Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/app/indexPage.template.html Iterates through a list of stylesheets and adds them to the document using the addTag macro. Ensures all required CSS files are loaded. ```html {% for stylesheet in doc.stylesheets %} {$- addTag('link', {rel: 'stylesheet', href: stylesheet, type: 'text/css'}) -$} {% endfor %} ``` -------------------------------- ### Function Syntax Macro Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/lib/macros.html Generates a formatted string representing the syntax of a function, including its name and parameters. Parameters are enclosed in backticks and separated by commas. Optional parameters are indicated with square brackets. ```html {% macro functionSyntax(fn) %} {%- set sep = joiner(', ') -%} {% marked -%} `{$ fn.name $}({%- for param in fn.params -%} {$ sep() $} {%- if param.type.optional %} [{% endif -%} {$ param.name $} {%- if param.type.optional %} ]{% endif -%} {%- endfor -%});` {%- endmarked -%} {% endmacro -%} ``` -------------------------------- ### ng-include with Primitive Binding Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Scopes Demonstrates how ng-include creates a new child scope that shadows parent scope primitives. Use `$parent` to bind to the parent scope's primitive. ```html
``` ```html
``` ```html ``` -------------------------------- ### AngularJS Pluralization Demo Source: https://github.com/angular/angular.js/blob/master/i18n/e2e/localeTest_en.html Placeholder for demonstrating pluralization rules. Actual pluralization logic would be implemented using the 'plural' filter with appropriate cases. ```html * * * ``` -------------------------------- ### Filter Usage in JavaScript Source: https://github.com/angular/angular.js/blob/master/docs/config/templates/ngdoc/api/filter.template.html Shows how to invoke filters programmatically using the $filter service in JavaScript. ```APIDOC ## Filter in JavaScript ### Description Invokes a filter using the $filter service in JavaScript to transform data. ### Usage ```javascript $filter('filterName')(param1, param2, ...) ``` ### Parameters (Parameters are documented separately and included via include directive in the source template) ``` -------------------------------- ### Observing Attribute Changes with $attributes.$observe Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Directives Use $attributes.$observe to asynchronously react to changes in attributes containing {{}} expressions. The callback receives the new value. This is similar to $scope.$watch but for attributes. ```javascript $attributes.$observe('myOtherAttribute', function(newValue)) ``` -------------------------------- ### Directive Linking Function Options Source: https://github.com/angular/angular.js/wiki/Dev-Guide:-Understanding-Directives Demonstrates the two ways to define a linking function for a directive: as a single function (defaults to post-linking) or as an object with pre and post linking functions. ```javascript link: function LinkingFunction($scope, $element, $attributes) { ... } ``` ```javascript link: { pre: function PreLinkingFunction($scope, $element, $attributes) { ... }, post: function PostLinkingFunction($scope, $element, $attributes) { ... }, } ``` -------------------------------- ### Interpolation with Filter Source: https://github.com/angular/angular.js/blob/master/benchmarks/largetable-bp/main.html Demonstrates using filters within interpolation to format data. ```html interpolation + filter: {{column.i | noop}}:{{column.j | noop}}| ``` -------------------------------- ### ng-include with Object Property Model Source: https://github.com/angular/angular.js/wiki/Understanding-Scopes Shows how ng-include with an object property model correctly utilizes prototypal inheritance to bind to the parent scope. ```html
``` -------------------------------- ### Verify Empty ng-jq Initialization Source: https://github.com/angular/angular.js/blob/master/test/e2e/fixtures/ng-jq/index.html This code verifies that an empty ng-jq initialization does not access `window['']`. This is important for preventing unexpected behavior when jQuery is not globally available or is aliased. ```javascript window[''] = window.jQuery; ``` -------------------------------- ### Collect Contributors List Source: https://github.com/angular/angular.js/blob/master/RELEASE.md Use git log to generate a sorted, unique list of contributors between two version tags. This is useful for acknowledging contributors in release announcements. ```bash git log --format='%aN' v1.2.12..v1.2.13 | sort -u ``` -------------------------------- ### Interpolation with Function Invocation Source: https://github.com/angular/angular.js/blob/master/benchmarks/largetable-bp/main.html Shows interpolation combined with calling functions to display dynamic data. ```html interpolation + fnInvocation: {{column.iFn()}}:{{column.jFn()}}| ```