diff options
| author | Igor Minar | 2010-11-23 16:10:14 -0800 |
|---|---|---|
| committer | Igor Minar | 2010-11-23 16:10:14 -0800 |
| commit | a0e8c45880c71838fc92a9251b278d507b30dec9 (patch) | |
| tree | a86b3dce084354dac2a282350c83c1554c8c0820 /src/apis.js | |
| parent | 870547d185ce755d695cc75d908c1deb78d89f49 (diff) | |
| download | angular.js-a0e8c45880c71838fc92a9251b278d507b30dec9.tar.bz2 | |
docs for angular.Array.remove
Diffstat (limited to 'src/apis.js')
| -rw-r--r-- | src/apis.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/apis.js b/src/apis.js index e39c7c04..e17447eb 100644 --- a/src/apis.js +++ b/src/apis.js @@ -66,6 +66,44 @@ var angularArray = { * @ngdoc function * @name angular.Array.remove * @function + * + * @description + * Modifies `array` by removing an element from it. The element will be looked up using the + * {@link angular.Array.indexOf indexOf} function on the `array` and only the first instance of + * the element will be removed. + * + * @param {Array} array Array from which an element should be removed. + * @param {*} value Element to be removed. + * @returns {*} The removed element. + * + * @example + <ul ng:init="tasks=['Learn Angular', 'Read Documentation', + 'Check out demos', 'Build cool applications']"> + <li ng:repeat="task in tasks"> + {{task}} [<a href="" ng:click="tasks.$remove(task)">X</a>] + </li> + </ul> + <hr/> + tasks = {{tasks}} + + @scenario + it('should initialize the task list with for tasks', function() { + expect(repeater('.doc-example ul li', 'task in tasks').count()).toBe(4); + expect(repeater('.doc-example ul li', 'task in tasks').column('task')). + toEqual(['Learn Angular', 'Read Documentation', 'Check out demos', + 'Build cool applications']); + }); + + it('should initialize the task list with for tasks', function() { + element('.doc-example ul li a:contains("X"):first').click(); + expect(repeater('.doc-example ul li', 'task in tasks').count()).toBe(3); + + element('.doc-example ul li a:contains("X"):last').click(); + expect(repeater('.doc-example ul li', 'task in tasks').count()).toBe(2); + + expect(repeater('.doc-example ul li', 'task in tasks').column('task')). + toEqual(['Read Documentation', 'Check out demos']); + }); */ 'remove':function(array, value) { var index = indexOf(array, value); |
