ng 核心API

1 篇文章 / 0 new
author
ng 核心API

ng (core module)

ng module 是AngularJS程序啟動時即載入的核心模組. 提供許多應用的service與函式. 下為該模組所提供的 services/factories, filters, directives and testing 等元件清單.
 

Module Components

Function

Name Description
angular.lowercase 字串轉為小寫
angular.uppercase 字串轉為大寫
angular.forEach Invokes the iterator function once for each item in obj collection, which can be either an
angular.extend Extends the destination object dst by copying all of the properties from the src object(s)
angular.noop A function that performs no operations. This function can be useful when writing code in the
angular.identity A function that returns its first argument. This function is useful when writing code in the
angular.isUndefined Determines if a reference is undefined.
angular.isDefined Determines if a reference is defined.
angular.isObject Determines if a reference is an Object. Unlike typeof in JavaScript, nulls are not
angular.isString Determines if a reference is a String.
angular.isNumber Determines if a reference is a Number.
angular.isDate Determines if a value is a date.
angular.isArray Determines if a reference is an Array.
angular.isFunction Determines if a reference is a Function.
angular.isElement Determines if a reference is a DOM element (or wrapped jQuery element).
angular.copy Creates a deep copy of source, which should be an object or an array.
angular.equals Determines if two objects or two values are equivalent. Supports value types, regular
angular.bind Returns a function which calls function fn bound to self (self becomes the this for
angular.toJson Serializes input into a JSON-formatted string. Properties with leading $ characters will be
angular.fromJson Deserializes a JSON string.
angular.bootstrap Use this function to manually start up angular application.
angular.injector Creates an injector function that can be used for retrieving services as well as for
angular.element Wraps a raw DOM element or HTML string as a jQuery element.
angular.module 全域型態, 任何controller, service...等均須透過此來建立, 登錄與檢索Angular

Directive

Name Description
ngApp 指示該頁面 auto-bootstrap an AngularJS application. The ngApp directive
a Modifies the default behavior of the html A tag so that the default action is prevented when
ngHref Using Angular markup like {{hash}} in an href attribute will
ngSrc Using Angular markup like {{hash}} in a src attribute doesn't
ngSrcset Using Angular markup like {{hash}} in a srcset attribute doesn't
ngDisabled The following markup will make the button enabled on Chrome/Firefox but not on IE8 and older IEs:
ngChecked The HTML specification does not require browsers to preserve the values of boolean attributes
ngReadonly The HTML specification does not require browsers to preserve the values of boolean attributes
ngSelected The HTML specification does not require browsers to preserve the values of boolean attributes
ngOpen The HTML specification does not require browsers to preserve the values of boolean attributes
ngForm Nestable alias of form directive. HTML
form Directive that instantiates
textarea HTML textarea element control with angular data-binding. The data-binding and validation
input HTML input element control with angular data-binding. Input control follows HTML5 input types
ngModel The ngModel directive binds an input,select, textarea (or custom form control) to a
ngChange Evaluate the given expression when the user changes the input.
ngList Text input that converts between a delimited string and an array of strings. The delimiter
ngValue Binds the given expression to the value of input[select] or input[radio], so
ngBind The ngBind attribute tells Angular to replace the text content of the specified HTML element
ngBindTemplate The ngBindTemplate directive specifies that the element
ngBindHtml Creates a binding that will innerHTML the result of evaluating the expression into the current
ngClass The ngClass directive allows you to dynamically set CSS classes on an HTML element by databinding
ngClassOdd The ngClassOdd and ngClassEven directives work exactly as
ngClassEven The ngClassOdd and ngClassEven directives work exactly as
ngCloak The ngCloak directive is used to prevent the Angular html template from being briefly
ngController The ngController directive attaches a controller class to the view. This is a key aspect of how angular
ngCsp Enables CSP (Content Security Policy) support.
ngClick The ngClick directive allows you to specify custom behavior when
ngDblclick The ngDblclick directive allows you to specify custom behavior on a dblclick event.
ngMousedown The ngMousedown directive allows you to specify custom behavior on mousedown event.
ngMouseup Specify custom behavior on mouseup event.
ngMouseover Specify custom behavior on mouseover event.
ngMouseenter Specify custom behavior on mouseenter event.
ngMouseleave Specify custom behavior on mouseleave event.
ngMousemove Specify custom behavior on mousemove event.
ngKeydown Specify custom behavior on keydown event.
ngKeyup Specify custom behavior on keyup event.
ngKeypress Specify custom behavior on keypress event.
ngSubmit Enables binding angular expressions to onsubmit events.
ngFocus Specify custom behavior on focus event.
ngBlur Specify custom behavior on blur event.
ngCopy Specify custom behavior on copy event.
ngCut Specify custom behavior on cut event.
ngPaste Specify custom behavior on paste event.
ngIf The ngIf directive removes or recreates a portion of the DOM tree based on an
ngInclude Fetches, compiles and includes an external HTML fragment.
ngInit The ngInit directive allows you to evaluate an expression in the
ngNonBindable The ngNonBindable directive tells Angular not to compile or bind the contents of the current
ngPluralize ngPluralizeis a directive that displays messages according to en-US localization rules.
ngRepeat The ngRepeat directive instantiates a template once per item from a collection. Each template
ngShow The ngShow directive shows or hides the given HTML element based on the expression
ngHide The ngHide directive shows or hides the given HTML element based on the expression
ngStyle The ngStyle directive allows you to set CSS style on an HTML element conditionally.
ngSwitch The ngSwitch directive is used to conditionally swap DOM structure on your template based on a scope expression.
ngTransclude Directive that marks the insertion point for the transcluded DOM of the nearest parent directive that uses transclusion.
script Load the content of a <script> element into $templateCache, so that the
select HTML SELECT element with angular data-binding.

Object

Name Description
angular.version An object that contains information about the current AngularJS version. This object has the

Type

Name Description
angular.Module Interface for configuring angular modules.
$compile.directive.Attributes A shared object between directive compile / linking functions which contains normalized DOM
form.FormController FormControllerkeeps track of all its controls and nested forms as well as state of them,
ngModel.NgModelController NgModelControllerprovides API for the ng-model directive. The controller contains
$rootScope.Scope A root scope can be retrieved using the $rootScope key from the

Service

Name Description
$anchorScroll When called, it checks current value of $location.hash() and scroll to related element,
$animate The $animate service provides rudimentary DOM manipulation functions to
$cacheFactory Factory that constructs cache objects and gives access to them.
$templateCache The first time a template is used, it is loaded in the template cache for quick retrieval. You
$compile Compiles an HTML string or DOM into a template and produces a template function, which
$controller $controllerservice is responsible for instantiating controllers.
$document A jQuery or jqLite wrapper for the browser's window.document object.
$exceptionHandler Any uncaught exception in angular expressions is delegated to this service.
$filter Filters are used for formatting data displayed to the user.
$http The $http service is a core Angular service that facilitates communication with the remote
$httpBackend HTTP backend used by the service that delegates to
$interpolate Compiles a string with markup into an interpolation function. This service is used by the
$interval Angular's wrapper for window.setInterval. The fn function is executed every delay
$locale $locale service provides localization rules for various Angular components. As of right now the
$location The $location service parses the URL in the browser address bar (based on the
$log Simple service for logging. Default implementation safely writes the message
$parse Converts Angular expression into a function.
$q A promise/deferred implementation inspired by Kris Kowal's Q.
$rootElement The root element of Angular application. This is either the element where {@link
$rootScope Every application has a single root scope.
$sceDelegate $sceDelegateis a service that is used by the $sce service to provide Strict
{@link module:ng.service:$sce $sce $sceis a service that provides Strict Contextual Escaping services to AngularJS.
$timeout Angular's wrapper for window.setTimeout. The fn function is wrapped into a try/catch
$window A reference to the browser's window object. While window

Provider

Name Description
$animateProvider Default implementation of $animate that doesn't perform any animations, instead just
$compileProvider  
$controllerProvider The $controller service is used by Angular to create new
$filterProvider Filters are just functions which transform input to an output. However filters need to be
$interpolateProvider Used for configuring the interpolation markup. Defaults to {{ and }}.
$locationProvider Use the $locationProvider to configure how the application deep linking paths are stored.
$logProvider Use the $logProvider to configure how the application logs messages
$parseProvider $parseProvidercan be used for configuring the default behavior of the $parse
$rootScopeProvider Provider for the $rootScope service.
$sceDelegateProvider The $sceDelegateProvider provider allows developers to configure the
{@link module:ng.provider:$sceProvider $sceProvider The $sceProvider provider allows developers to configure the $sce service.

Input

Name Description
input[text] Standard HTML text input with angular data binding.
input[number] Text input with number validation and transformation. Sets the number validation
input[url] Text input with URL validation. Sets the url validation error key if the content is not a
input[email] Text input with email validation. Sets the email validation error key if not a valid email
input[radio] HTML radio button.
input[checkbox] HTML checkbox.

Filter

Name Description
filter Selects a subset of items from array and returns it as a new array.
currency Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default
number Formats a number as text.
date Formats date to a string based on the requested format.
json Allows you to convert a JavaScript object into JSON string.
lowercase Converts string to lowercase.
uppercase Converts string to uppercase.
limitTo Creates a new array or string containing only a specified number of elements. The elements
orderBy Orders a specified array by the expression predicate.
Free Web Hosting