當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular.isArray函數代碼示例

本文整理匯總了TypeScript中angular.isArray函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isArray函數的具體用法?TypeScript isArray怎麽用?TypeScript isArray使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isArray函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

        this.settings = function(newSettings?: ISettings<T>) {
            if (ng1.isDefined(newSettings)) {

                // todo: don't modify newSettings object: this introduces unexpected side effects;
                // instead take a copy of newSettings

                if (newSettings.filterOptions){
                    newSettings.filterOptions = ng1.extend({}, _settings.filterOptions, newSettings.filterOptions);
                }
                if (newSettings.groupOptions){
                    newSettings.groupOptions = ng1.extend({}, _settings.groupOptions, newSettings.groupOptions);
                }

                if (ng1.isArray(newSettings.dataset)) {
                    //auto-set the total from passed in dataset
                    newSettings.total = newSettings.dataset.length;
                }

                var originalDataset = _settings.dataset;
                _settings = ng1.extend(_settings, newSettings);

                if (ng1.isArray(newSettings.dataset)) {
                    optimizeFilterDelay();
                }

                // note: using != as want null and undefined to be treated the same
                var hasDatasetChanged = newSettings.hasOwnProperty('dataset') && (newSettings.dataset != originalDataset);
                if (hasDatasetChanged) {
                    if (isCommittedDataset){
                        this.page(1); // reset page as a new dataset has been supplied
                    }
                    isCommittedDataset = false;

                    var fireEvent = function () {
                        ngTableEventsChannel.publishDatasetChanged(self, newSettings.dataset, originalDataset);
                    };

                    if (initialEvents){
                        initialEvents.push(fireEvent);
                    } else {
                        fireEvent();
                    }
                }
                log('ngTable: set settings', _settings);
                return this;
            }
            return _settings;
        };
開發者ID:Timeyit,項目名稱:main,代碼行數:48,代碼來源:ngTableParams.ts

示例2: function

    angular.forEach(rowLabelsElements, function (rowLabelElement, i) {
      rowLabelElement = jQuery(rowLabelElement)

      let rowModel = data[i]
      let rowText = rowLabelElement.text().trim()
      if (contentNotSupported || rowModel.content === undefined) {
        expect(rowText).to.be.eq(rowModel.name)
      } else {
        let rowHtmlModel = rowModel.content
        rowHtmlModel = rowHtmlModel.replace('{{row.model.name}}', rowModel.name)
        let expectedRowText = rowHtmlModel.replace(/<(?:.|\n)*?>/gm, '').trim() // Strip HTML
        expect(rowText).to.be.eq(expectedRowText)
      }

      if (rowModel.classes) {
        let rowClasses = rowModel.classes
        if (!angular.isArray(rowClasses)) {
          rowClasses = [rowClasses]
        }

        angular.forEach(rowClasses, function (rowClass) {
          expect(rowLabelElement.parents().hasClass(rowClass)).to.be.ok
        })
      }
    })
開發者ID:angular-gantt,項目名稱:angular-gantt,代碼行數:25,代碼來源:plugins.spec.ts

示例3: localeTextWithParams

	/**
	 * Apply locale string in format "...{0}...{1}..." and apply instead of '{n}' params[n]
	 * @param {string} locale text key. This key contains in resources.
	 * @param {strong} defaultValue. Default value if locale resource wasn't found.
	 * @param {Array} params. Additional params.
	 * @returns {string}. Localized text. 
	 */
	localeTextWithParams(key: string, defaultValue: string, params: string[]): string {
		let result = this.localeText(key, defaultValue);
		if (angular.isArray(params))
			params.forEach((param, iParam) =>
				result = result.replaceAll(`{${iParam}}`, param));
		return result;
	}
開發者ID:izenda,項目名稱:resources,代碼行數:14,代碼來源:localization-service.ts

示例4: it

    it('should be wrapped in an array if array: true', function() {
      const m = $umf.compile('/foo?param1', { params: { param1: { array: true } } });

      // empty array [] is treated like "undefined"
      expect(m.format({ param1: undefined })).toBe('/foo');
      expect(m.format({ param1: [] })).toBe('/foo');
      expect(m.format({ param1: '' })).toBe('/foo');
      expect(m.format({ param1: '1' })).toBe('/foo?param1=1');
      expect(m.format({ param1: ['1'] })).toBe('/foo?param1=1');
      expect(m.format({ param1: ['1', '2'] })).toBe('/foo?param1=1&param1=2');

      expect(m.exec('/foo')).toEqual({ param1: undefined });
      expect(m.exec('/foo', {})).toEqual({ param1: undefined });
      expect(m.exec('/foo', { param1: '' })).toEqual({ param1: undefined });
      expect(m.exec('/foo', { param1: '1' })).toEqual({ param1: ['1'] });
      expect(m.exec('/foo', { param1: ['1', '2'] })).toEqual({ param1: ['1', '2'] });

      $url.url('/foo');
      expect(m.exec($url.path(), $url.search())).toEqual({ param1: undefined });
      $url.url('/foo?param1=');
      expect(m.exec($url.path(), $url.search())).toEqual({ param1: undefined });
      $url.url('/foo?param1=bar');
      expect(m.exec($url.path(), $url.search())).toEqual({ param1: ['bar'] });
      $url.url('/foo?param1=bar&param1=baz');
      if (angular.isArray($url.search()))
        // conditional for angular 1.0.8
        expect(m.exec($url.path(), $url.search())).toEqual({ param1: ['bar', 'baz'] });

      expect(m.format({})).toBe('/foo');
      expect(m.format({ param1: undefined })).toBe('/foo');
      expect(m.format({ param1: '' })).toBe('/foo');
      expect(m.format({ param1: 'bar' })).toBe('/foo?param1=bar');
      expect(m.format({ param1: ['bar'] })).toBe('/foo?param1=bar');
      expect(m.format({ param1: ['bar', 'baz'] })).toBe('/foo?param1=bar&param1=baz');
    });
開發者ID:angular-ui,項目名稱:ui-router,代碼行數:35,代碼來源:urlMatcherFactorySpec.ts

示例5: function

        return function (items: any, filterOn: any) {

            if (filterOn === false) {
                return items;
            }

            if ((filterOn || angular.isUndefined(filterOn)) && angular.isArray(items)) {
                var hashCheck: any = {}, newItems: any[] = [];

                var extractValueToCompare = function (item: any) {
                    if (angular.isObject(item) && angular.isString(filterOn)) {
                        return item[filterOn];
                    } else {
                        return item;
                    }
                };

                angular.forEach(items, (item: any)=> {
                    var valueToCheck, isDuplicate = false;

                    for (var i = 0; i < newItems.length; i++) {
                        if (angular.equals(extractValueToCompare(newItems[i]), extractValueToCompare(item))) {
                            isDuplicate = true;
                            break;
                        }
                    }
                    if (!isDuplicate) {
                        newItems.push(item);
                    }

                });
                items = newItems;
            }
            return items;
        };
開發者ID:prashanthc97,項目名稱:kylo,代碼行數:35,代碼來源:filters.ts

示例6: customizer

export function assignPartialDeep<T extends TPartial, TPartial>(
    destination: T, 
    partial: TPartial,
    optionalPropSelector: (key: string, destination: T) => boolean = () => false,
    customizer: (destValue: any, srcValue: any, key: string) => any = () => undefined
 ) {
    const keys = Object.keys(partial);
    for(const key of keys) {
        let srcVal = partial[key];
        if (srcVal === undefined) {
            if (optionalPropSelector(key, destination)){
                destination[key] = srcVal;
            } else {
                // don't assign undefined to destination
            }
            continue;
        }

        const destVal = destination[key];
        const customVal = customizer(destVal, srcVal, key);
        if (customVal !== undefined){
            destination[key] = customVal;
        } else if (ng1.isArray(srcVal)) {
            destination[key] = [...srcVal];
        } else if (!ng1.isObject(srcVal)) {
            destination[key] = srcVal;
        } else {
            destination[key] = assignPartialDeep(destVal, srcVal);
        }
    }
    return destination;
}
開發者ID:QuBaR,項目名稱:ng-table,代碼行數:32,代碼來源:assign-partial-deep.ts

示例7:

 const removePrototype = (srcVal: any, objVal: any) => {
     if (ng1.isObject(objVal) && !ng1.isArray(objVal)) {
         return _.toPlainObject(objVal);
     } else {
         return objVal;
     }
 };
開發者ID:QuBaR,項目名稱:ng-table,代碼行數:7,代碼來源:jasmine-extensions.ts

示例8: if

			constraintFilters.forEach(constraintFilter => {
				const constraintFilterOperatorValue = constraintFilter && constraintFilter.operator ? constraintFilter.operator.value : '';

				if (constraintFilter.field !== null && angular.isObject(constraintFilter.operator)
					&& constraintFilterOperatorValue !== '' && angular.isArray(constraintFilter.values)
					&& constraintFilter.values.length > 0) {
					const constraintParamPart = {};
					constraintParamPart[`fc${counter}`] = constraintFilter.field.sysname;
					constraintParamPart[`fo${counter}`] = constraintFilterOperatorValue;
					const constraintOperatorType = this.getFieldFilterOperatorValueType(constraintFilter.operator);
					if (constraintOperatorType === 'twoValues') {
						constraintParamPart[`fvl${counter}`] = constraintFilter.values[0];
						constraintParamPart[`fvr${counter}`] = constraintFilter.values[1];
					} else if (constraintOperatorType === 'twoDates') {
						constraintParamPart[`fvl${counter}`] = moment(constraintFilter.values[0]).format(this.$izendaSettingsService.getDateFormat().shortDate);
						constraintParamPart[`fvr${counter}`] = moment(constraintFilter.values[1]).format(this.$izendaSettingsService.getDateFormat().shortDate);
					} else if (constraintOperatorType === 'oneDate') {
						constraintParamPart[`fvl${counter}`] = moment(constraintFilter.values[0]).format(this.$izendaSettingsService.getDateFormat().shortDate);
					} else if (constraintOperatorType === 'field') {
						const val = angular.isObject(constraintFilter.values[0])
							? constraintFilter.values[0].sysname
							: '';
						constraintParamPart[`fvl${counter}`] = val;
					} else {
						constraintParamPart[`fvl${counter}`] = constraintFilter.values.join(',');
					}

					angular.extend(queryParams, constraintParamPart);
					counter++;
				}
			});
開發者ID:izenda,項目名稱:resources,代碼行數:31,代碼來源:instant-report-query.ts

示例9: function

angular.module("eperusteApp").directive("oikeustarkastelu", function(PerusteprojektiOikeudetService) {
    return {
        restrict: "A",
        link(scope, element: any, attrs: any) {
            var oikeudet = scope.$eval(attrs.oikeustarkastelu);
            if (!angular.isArray(oikeudet)) {
                oikeudet = [oikeudet];
            }
            if (
                !_.any(oikeudet, function(o: any) {
                    return PerusteprojektiOikeudetService.onkoOikeudet(o.target, o.permission);
                })
            ) {
                // Ei toimi jos ng-disabled myös käytössä
                /*
                if (element.prop("tagName") === "BUTTON") {
                    element.prop("disabled", true);
                } else {
                    element.hide();
                }
                */
                element.hide();
            }
        }
    };
});
開發者ID:Opetushallitus,項目名稱:eperusteet,代碼行數:26,代碼來源:oikeustarkastelu.ts

示例10: function

        this.appendTransform = function (defaults: any, transform: any) {

            // We can't guarantee that the default transformation is an array
            defaults = angular.isArray(defaults) ? defaults : [defaults];

            // Append the new transformation to the defaults
            return defaults.concat(transform);
        }
開發者ID:prashanthc97,項目名稱:kylo,代碼行數:8,代碼來源:HttpService.ts


注:本文中的angular.isArray函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。