Filters
Formats a number as a currency (ie $1,234.56).
|
|
Selects a subset of items from array. Expression takes string|Object|function()
|
Convert a JavaScript object into JSON string.
|
Creates a new array containing only a specified number of elements in an array.
|
Finds links in text input and turns them into html links.
|
Converts string to lowercase.
|
Formats a number as text. If the input is not a number an empty string is returned.
|
Predicate is function(*)|string|Array. Reverse is boolean
|
Converts string to uppercase.
|
You can inject the $filter service and do $filter('filterName')(value[, :optionalParam][, :optionalParam]) in use it in your javascript.
1 Requires ngSanitize Module
Services
$anchorScroll |
$cacheFactory |
compiledHtml = $compile(html)(scope) |
$controller |
$cookieStore |
$document |
$exceptionHandler(exception[, cause]) |
$filter(name) |
$http[(options)] |
$httpBackend |
$injector |
$interpolate(text[, mustHaveExpression]) |
$locale |
$location |
$log |
$parse(expression) |
$provide |
$q |
$resource(url[, paramDefaults][, actions]) |
$rootElement |
$rootScope |
$route |
$routeParams |
$routeProvider |
$sanitize(html) |
$scope See $rootScope |
$templateCache |
$timeout(fn[, delay][, invokeApply]) |
$window |
Directive Definition Object
name {string} Name of the current scope. Optional defaults to the name at registration.
|
priority {integer} Specifies order multiple directives apply on single DOM element (higher = first)
|
terminal {true} Current priority will be last set of directives to execute
|
scope {true | object} True - create child scope. Undefined|false - use parent scope. {} - isolate scope (with specified attributes/scope variables passed): @ or @attr - bind local model to value of DOM attribute (string), = or =attr - bi-directional binding between local model and the parent scope, & or &attr - execute an expression in context of parent. Reference attr OR assumes model of same name
|
controller function($scope, $element, $attrs, $transclude) Controller constructor function instantiated before pre-linking phase and shared with other directives if requested by name
|
require {string | array[strings]} Require another controller (ngModel). Prefixes: ? - Don't raise error. ^ - Look on parent elements too
|
restrict {string: 'EACM'} E - Element: <my-directive />. A - Attribute (default): <div my-directive="exp" />. C - Class: <div class="my-directive: exp;" />. M - Comment: <!-- directive: my-directive exp -->
|
template {string} Replace current element with contents and migrates all attributes / classes
|
templateUrl {string} Same as template but the template is loaded from the specified URL
|
replace {boolean} true: template replaces element instead of appending
|
transclude {boolean} Compiles contents on parent (pre-isolate) scope. Usually used with ngTransclude & templates.
|
compile function(tElement, tAttrs, fn transclude(function(scope, cloneLinkingFn) ) returns link() For transforming the template (rare, run once per template instance).
|
link function(scope, iElement, iAttrs, controller) Executed after template is cloned (run once per clone). Contains most logic (DOM listeners, etc). Controller can be an array.
|
|
|
Directives
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<input ng-pattern="/regex/" ng-minlength ng-maxlength ng-required |
|
<input type="checkbox" ng-true-value="plaintext" ng-false-value="plaintext"> |
|
|
|
|
|
|
|
<select ng-multiple> |
|
|
|
|
|
|
|
|
|
|
ng-switch-when="plaintext" |
ng-switch-default |
|
|
|
Bold means the actual directive
Italics mean optional
Pipes mean either|or
Plaintext means no string encapsulation
Superscript means notes or context
<Brackets> mean tag comptibility
Lack of <brackets> means the attribute can apply to any tag
Module
Use this method to register work which needs to be performed on module loading.
|
Because the constant are fixed, they get applied before other provide methods.
|
|
|
|
|
|
Use this method to register work which needs to be performed when the injector with with the current module is finished loading.
|
value(name, object)
|
Name of the module.
|
Holds the list of modules which the injector will load before the current module is loaded.
|
Scope Properties and Methods
$root or $rootScope Move to the top-most $scope (ng-app)
|
$parent Move to the immediate parent of the current $scope
|
$id Auto generated Unique ID
|
$destroy (event) Broadcasted when a scope and its children are being destroyed
|
$apply(exp) Executes logic within the AngularJS context and refreshes all models checks.
|
$broadcast(name, args) Dispatches an event name downwards to all child scopes
|
$destroy() Removes the current scope (and all of its children) from the parent scope
|
$digest() Process all of the watchers of the current scope and its children. Since watchers can change models, they will continue firing until all changes stop. BEWARE OF RECURSIVE CODE
|
$emit(name, args) Dispatches an event name upwards through the scope hierarchy
|
$eval(expression) Executes the expression on the current scope and returns the result
|
$evalAsync(expression) Executes the expression on the current scope at a later point in time
|
$new(isolate) Creates a new child scope
|
$on(name, listener) Listens on events of a given type
|
$watch(watchExp, listener(newVal, oldVal, scope), objectEquality) Watch a model (exp) for changes and fires the listener callback. Pass true as a third argument to watch an object's properties too.
|
The following directives create child scopes: ngInclude, ngSwitch, ngRepeat, ngController, uiIf. Calls to the same ngController will create multiple instances and do not share scopes. Remember to traverse up the tree to affect primitives on the intended scope: ng-click="$parent.showPage=true"
|
|
Global Functions
Returns a function which calls function fn bound to self (self becomes the this for fn).
|
Use this function to manually start up angular application.
|
Creates a deep copy of source, which should be an object or an array.
|
Wraps a raw DOM element or HTML string as a jQuery element.
|
Determines if two objects or two values are equivalent.
|
Extends the destination object dst by copying all of the properties from the src object(s) to dst.
|
Invokes the iterator function once for each item in obj collection, which can be either an object or an array.
|
Deserializes a JSON string.
|
A function that returns its first argument. This function is useful when writing code in the functional style.
|
Creates an injector function that can be used for retrieving services as well as for dependency injection.
|
Determines if a reference is an Array.
|
Determines if a value is a date.
|
Determines if a reference is defined.
|
Determines if a reference is a DOM element (or wrapped jQuery element).
|
Determines if a reference is a Function.
|
Determines if a reference is a Number.
|
Determines if a reference is an Object. Unlike typeof in JavaScript, nulls are not considered to be objects.
|
Determines if a reference is a String.
|
Determines if a reference is undefined.
|
Converts the specified string to lowercase.
|
Namespace from 'angular-mocks.js' which contains testing related code.
|
The angular.module is a global place for creating and registering Angular modules. Requires argument always creates a new module.
|
A function that performs no operations.
|
Serializes input into a JSON-formatted string.
|
Converts the specified string to uppercase.
|
An object that contains information about the current AngularJS version.
|
NgModelController
$render() |
Called when the view needs to be updated. It is expected that the user of the ng-model directive will implement this method. |
$setValidity(validationErrorKey, isValid) |
$setViewValue(value) |
$viewValue |
mixed |
$modelValue |
mixed |
$parsers |
array of function after reading val from DOM to sanitize / convert / validate the value |
$formatters |
array of functions to convert / validate the value |
$error |
object |
$pristine |
boolean |
$dirty |
boolean |
$valid |
boolean |
$invalid |
boolean |
Deferred and Promise
$q.all([array of promises]) Creates a Deferred object which represents a task which will finish in the future.
|
$q. defer() Creates a Deferred object which represents a task which will finish in the future.
|
$q.reject(reason) Creates a promise that is resolved as rejected with the specified reason
|
$q.when(value) Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise
|
Deferred.resolve(value) Resolves the derived promise with the value
|
Deferred.reject(reason) Rejects the derived promise with the reason
|
Deferred.promise Promise object associated with this deferred
|
Promise.then(successCallback, errorCallback) |
|
Created By
https://aloneonahill.com
Metadata
Favourited By
and 128 more ...
Comments
Vinay, 20:00 9 Aug 12
I think the angularjs fiddles is a great resource, add this to the cheatsheet:
https://github.com/angular/angular.js/wiki/JsFiddle-Examples
Gary Weaver 10:01 20 May 13
Great stuff! Would be good to add compatible Angular version(s) at the top.
Dillon 10:19 20 May 13
Is it just me, or does the 'find' not work for this page? If i type in 'ng-app' it doesn't find anything...
DaveChild, 13:13 20 May 13
Hi Dillon. Well spotted - looks like an issue with JavaScript handling of shy hyphens, which are used to help cheat sheet text wrap well. I'm working on a solution now.
DaveChild, 13:27 20 May 13
Hi Dillon. I've fixed the search and "ng-app" now returns the right rows. Thanks for letting me know about the problem!
DaveChild, 11:22 20 May 13
Dean, your excellent cheat sheet made the front page of Hacker News: https://news.ycombinator.com/item?id=5727988
ProLoser, 11:25 20 May 13
Cheatography's built-in search sucks. You're better off using your browser to do a native page search
DaveChild, 13:38 20 May 13
The build-in search was choking on soft hyphens, but I've fixed the problem now and search is working normally.
ProLoser, 01:51 21 May 13
Hey Dave!
I had no idea you were still working on this website, I was under the impression it was one of those side projects that just fell by the wayside.
HOW do I let other people collaborate on the cheat sheet with me? It's really annoying that I'm the only one who can work on a sheet.
Also, have you considered supporting hyperlinks (I know sheets are designed to be printed) like [test](http://example.com)
Also, can you add support for <br> so that I can list sub-details instead of cramming them together like I had to for 'restÂrict'
Also, how about descriptions at the TOP of content panes?
Also, maybe add underscore?
DaveChild, 19:15 28 May 13
Not exactly by the wayside, but I've been struggling with the new PDF builder for ages. Didn't seem to be much point in working on anything else until the compilation process and builder were fixed (and both are almost finished).
Collaboration is something I'm going to be adding in the future, but I'm not planning much until after the builder stuff is done. Hyperlinks in that style and line breaks are both good ideas, and as above - as soon as the new builder is done those are on the list. Line breaks will be a little tricky, as the new builder does a lot of line count estimation to try and paginate the PDFs better, but definitely something I want to add.
For underscore, do you mean in the titles? I'll add that in the current round of dev.
ProLoser, 19:28 28 May 13
I'm just talking about having more formatting options at my disposal. Personally, this specific cheatsheet isn't super PDF friendly, and I think almost everyone can 'print to pdf' nowadays, so it might be easier to focus on a simple print stylesheet.
Bruno Felthes 14:15 13 Feb 14
Include the ng-animation tag.
Some good samples at the site:
http://www.nganimate.org
Karin 07:48 19 Jun 14
The PDFs don't display the text correctly.
Johannes 08:31 9 Oct 14
ng-if is missin in the list of directives.
Besides great work.
RAMYA 14:47 30 Jul 15
Hi,
I was working on showing a popover on ng-click of a button.
I have an issue, the popover shows up after the second click on the button. Am not sure why this is happening,please let me know if am missing something.
Regards
Amit Patekar 11:40 27 Oct 15
Awesome stuff. Keep on adding more good stuff here. Also it will be great if you can put last updated date, so that visitors know when new stuff is added to this cheat sheet. Anyways good work.
Ryan Hinton 09:23 15 Feb 16
The PDF is not displaying correctly. It cuts the top of every letter and it is almost too difficult to read. I wanted to print it out to post it, but it is not easily readable, unfortunately. Is it possible this can be fixed?
Thank you.
alinamike, 14:55 17 Jan 17
new concept everybody should not full of awareness but it is good for us all of people shopping online easy
Husell, 13:08 2 Feb 20
I am studying Angular right now. This cheat sheet will definitely come in handy for me. Thanks!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by ProLoser