angular.Array.remove

Work In Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

Modifies array by removing an element from it. The element will be looked up using the indexOf function on the array and only the first instance of the element will be removed.

Note: this function is used to augment the Array type in angular expressions. See angular.Array for more info.

Usage

angular.Array.remove(array, value);

Parameters

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}} 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']); });