Angular 方法

来源:互联网 发布:妖气漫画网软件 编辑:程序博客网 时间:2024/05/20 05:31

1. angular.bootstrap

Use this function to manually start up angular application.

Angular will detect if it has been loaded into the browser more than once and only allow the first loaded script to be bootstrapped and will report a warning to the browser console for each of the subsequent scripts. This prevents strange results in applications, where otherwise multiple instances of Angular try to work on the DOM.

用法:angular.bootstrap(element, [modules]);

 

2. angualr.copy

Creates a deep copy of source, which should be an object or an array.

· If no destination is supplied, a copy of the object or array is created.

· If a destination is provided, all of its elements (for array) or properties (for objects) are deleted and then all elements/properties from the source are copied to it.

· If source is not an object or array (inc. null and undefined), source is returned.

· If source is identical to 'destination' an exception will be thrown.

3. angular.element

Wraps a raw DOM element or HTML string as a jQuery element.

把原生的DOM元素或者HTML字符串作包装成JQuery元素

4.angular.fromJson

Deserializes a JSON string.反序列化json字符串

5.angular.injector

Creates an injector function that can be used for retrieving services as well as for dependency injection (seedependency injection).

6.angular.isArray

Determines if a reference is an Array.

7.angular.isDate

Determines if a value is a date.

8. angular.isDefined

Determines if a reference is defined.

9.angular.isElement

Determines if a reference is a DOM element (or wrapped jQuery element).

10.angular.isNumber

Determines if a reference is a Number.

11.angular.isString

Determines if a reference is a String.

12.angular.isUndefined

Determines if a reference is undefined.

13.angular.lowercase/angular.uppercase

Converts the specified string to lowercase/uppercase.

14.angular.toJson

Serializes input into a JSON-formatted string. Properties with leading $ characters will be stripped since angular uses this notation internally.

15. angualr.module

A module is a collection of services, directives, controllers, filters, and configuration information. angular.module is used to configure the$injector.

// Create a new modulevar myModule = angular.module('myModule', []);// register a new servicemyModule.value('appName', 'MyCoolApp');// configure existing services inside initialization blocks.myModule.config(['$locationProvider', function($locationProvider) {  // Configure existing providers  $locationProvider.hashPrefix('!');}]);

Then you can create an injector and load your modules like this:

var injector = angular.injector(['ng', 'myModule'])

However it's more likely that you'll just use ngApp or angular.bootstrap to simplify this process for you.


Usage

angular.module(name, [requires], [configFn]);

Arguments

ParamTypeDetailsnamestring

The name of the module to create or retrieve.

requires
(optional)
!Array.<string>=

If specified then new module is being created. If unspecified then the module is being retrieved for further configuration.

configFn
(optional)
Function=

Optional configuration function for the module. Same as Module#config().

Returns

module

new module with the angular.Module api.


以上内容整理了官网


 

 

 

 

 

 

 

 

 

 

 

 

 

 

0 0
原创粉丝点击