ampersand-select-view.js
function(value) {
        var model;
        if (this.options.isCollection) {
            // find value in collection, error if no model found
            if (this.options.indexOf(value) === -1) model = this.getModelForId(value);
            else model = value;
            if (!model) throw new Error('model or model idAttribute not found in options collection');
            return this.yieldModel ? model : model[this.idAttribute];
        } else if (Array.isArray(this.options)) {
            // find value value in options array
            // find option, formatted [['val', 'text'], ...]
            if (this.options.length && Array.isArray(this.options[0])) {
                for (var i = this.options.length - 1; i >= 0; i--) {
                    if (this.options[i][0] == value) return this.options[i];
                }
            }
            // find option, formatted ['valAndText', ...] format
            if (this.options.length && this.options.indexOf(value) !== -1) return value;
            throw new Error('value not in set of provided options');
        }
        throw new Error('select option set invalid');
    }
function(value) {
        var model;
        if (this.options.isCollection) {
            // find value in collection, error if no model found
            if (this.options.indexOf(value) === -1) model = this.getModelForId(value);
            else model = value;
            if (!model) throw new Error('model or model idAttribute not found in options collection');
            return this.yieldModel ? model : model[this.idAttribute];
        } else if (Array.isArray(this.options)) {
            // find value value in options array
            // find option, formatted [['val', 'text'], ...]
            if (this.options.length && Array.isArray(this.options[0])) {
                for (var i = this.options.length - 1; i >= 0; i--) {
                    if (this.options[i][0] == value) return this.options[i];
                }
            }
            // find option, formatted ['valAndText', ...] format
            if (this.options.length && this.options.indexOf(value) !== -1) return value;
            throw new Error('value not in set of provided options');
        }
        throw new Error('select option set invalid');
    }
function ( value ) { var model ; if ( this . options . isCollection ) { // find value in collection, error if no model found if ( this . options . indexOf ( value ) === - 1 ) model = this . getModelForId ( value ) ; else model = value ; if ( ! model ) throw new Error ( 'model or model idAttribute not found in options collection' ) ; return this . yieldModel ? model : model [ this . idAttribute ] ; } else if ( Array . isArray ( this . options ) ) { // find value value in options array // find option, formatted [['val', 'text'], ...] if ( this . options . length && Array . isArray ( this . options [ 0 ] ) ) { for ( var i = this . options . length - 1 ; i >= 0 ; i -- ) { if ( this . options [ i ] [ 0 ] == value ) return this . options [ i ] ; } } // find option, formatted ['valAndText', ...] format if ( this . options . length && this . options . indexOf ( value ) !== - 1 ) return value ; throw new Error ( 'value not in set of provided options' ) ; } throw new Error ( 'select option set invalid' ) ; }
Gets the option corresponding to provided value.
@param  {*} string, state, or model
@return {*} string, array, state, or model
Gets the option corresponding to provided value .