mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
docs for angular.Array.remove
This commit is contained in:
parent
a0e8c45880
commit
303a683081
1 changed files with 31 additions and 0 deletions
31
src/apis.js
31
src/apis.js
|
|
@ -46,6 +46,34 @@ var angularArray = {
|
|||
* @ngdoc function
|
||||
* @name angular.Array.indexOf
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Determines the index of `value` in `array`.
|
||||
*
|
||||
* Note: this function is used to augment the Array type in angular expressions. See
|
||||
* {@link angular.Array} for more info.
|
||||
*
|
||||
* @param {Array} array Array to search.
|
||||
* @param {*} value Value to search for.
|
||||
* @returns {number} The position of the element in `array`. The position is 0-based. `-1` is returned if the value can't be found.
|
||||
*
|
||||
* @example
|
||||
<div ng:init="books = ['Moby Dick', 'Great Gatsby', 'Romeo and Juliet']"></div>
|
||||
<input name='bookName' value='Romeo and Juliet'> <br>
|
||||
Index of '{{bookName}}' in the list {{books}} is <em>{{books.$indexOf(bookName)}}</em>.
|
||||
|
||||
@scenario
|
||||
it('should correctly calculate the initial index', function() {
|
||||
expect(binding('books.$indexOf(bookName)')).toBe('2');
|
||||
});
|
||||
|
||||
it('should recalculate', function() {
|
||||
input('bookName').enter('foo');
|
||||
expect(binding('books.$indexOf(bookName)')).toBe('-1');
|
||||
|
||||
input('bookName').enter('Moby Dick');
|
||||
expect(binding('books.$indexOf(bookName)')).toBe('0');
|
||||
});
|
||||
*/
|
||||
'indexOf': indexOf,
|
||||
'sum':function(array, expression) {
|
||||
|
|
@ -72,6 +100,9 @@ var angularArray = {
|
|||
* {@link angular.Array.indexOf 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
|
||||
* {@link angular.Array} for more info.
|
||||
*
|
||||
* @param {Array} array Array from which an element should be removed.
|
||||
* @param {*} value Element to be removed.
|
||||
* @returns {*} The removed element.
|
||||
|
|
|
|||
Loading…
Reference in a new issue