diff options
| author | Igor Minar | 2010-11-23 16:28:24 -0800 |
|---|---|---|
| committer | Igor Minar | 2010-11-23 16:28:24 -0800 |
| commit | 303a68308157b507daaf6506d4c91cca8618cbc5 (patch) | |
| tree | 956010307242192942ddecf6c4be21ba598a5c6f /src | |
| parent | a0e8c45880c71838fc92a9251b278d507b30dec9 (diff) | |
| download | angular.js-303a68308157b507daaf6506d4c91cca8618cbc5.tar.bz2 | |
docs for angular.Array.remove
Diffstat (limited to 'src')
| -rw-r--r-- | src/apis.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/apis.js b/src/apis.js index e17447eb..cb2eaf43 100644 --- a/src/apis.js +++ b/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. |
