本文整理汇总了TypeScript中@angular/core.forwardRef函数的典型用法代码示例。如果您正苦于以下问题:TypeScript forwardRef函数的具体用法?TypeScript forwardRef怎么用?TypeScript forwardRef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forwardRef函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: ValidatorProviderFactory
export function ValidatorProviderFactory(type: Type<any>): Provider {
return {
provide: NG_VALIDATORS,
useExisting: forwardRef(() => type),
multi: true
};
}
开发者ID:Nimzi-Git,项目名称:angular-io-datepicker,代码行数:7,代码来源:common.ts
示例2: createAccessorProvider
public static createAccessorProvider(component:any):any {
return {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => component),
multi: true
};
}
开发者ID:hguerrerojaime,项目名称:bong2,代码行数:7,代码来源:provider.utils.ts
示例3: ControlValueAccessorProviderFactory
export function ControlValueAccessorProviderFactory(type: Type<any>): Provider {
return {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => type),
multi: true
};
}
开发者ID:Nimzi-Git,项目名称:angular-io-datepicker,代码行数:7,代码来源:common.ts
示例4: forwardRef
import { Directive, forwardRef } from '@angular/core';
import { NG_VALIDATORS, Validator, AbstractControl } from '@angular/forms';
import { url } from './';
const URL_VALIDATOR: any = {
provide: NG_VALIDATORS,
useExisting: forwardRef(() => UrlValidator),
multi: true
};
@Directive({
selector: '[url][formControlName],[url][formControl],[url][ngModel]',
providers: [URL_VALIDATOR]
})
export class UrlValidator implements Validator {
validate(c: AbstractControl): {[key: string]: any} {
return url(c);
}
}
开发者ID:diandsonc,项目名称:ng2-validation,代码行数:20,代码来源:directive.ts
示例5: forwardRef
import { Directive, ElementRef, forwardRef } from "@angular/core";
import { NG_VALUE_ACCESSOR } from "@angular/forms";
import { BaseValueAccessor } from "./base-value-accessor";
import { View } from "tns-core-modules/ui/core/view";
const TEXT_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => TextValueAccessor),
multi: true,
};
export type TextView = {text: string} & View;
/**
* The accessor for writing a text and listening to changes that is used by the
* {@link NgModel} directives.
*
* ### Example
* ```
* <TextField [(ngModel)]="model.test">
* ```
*/
@Directive({
selector:
"TextField[ngModel],TextField[formControlName],TextField[formControl]," +
"textField[ngModel],textField[formControlName],textField[formControl]," +
"textfield[ngModel],textfield[formControlName],textfield[formControl]," +
"text-field[ngModel],text-field[formControlName],text-field[formControl]," +
"TextView[ngModel],TextView[formControlName],TextView[formControl]," +
"textView[ngModel],textView[formControlName],textView[formControl]," +
开发者ID:NathanWalker,项目名称:nativescript-angular,代码行数:31,代码来源:text-value-accessor.ts
示例6: forwardRef
import { Directive, ElementRef, forwardRef } from "@angular/core";
import { NG_VALUE_ACCESSOR } from "@angular/forms";
import { BaseValueAccessor } from "./base-value-accessor";
import { Slider } from "tns-core-modules/ui/slider";
const NUMBER_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NumberValueAccessor),
multi: true,
};
/**
* The accessor for setting a value and listening to changes that is used by the
* {@link NgModel}
*
* ### Example
* ```
* <Slider [(ngModel)]="model.test">
* ```
*/
@Directive({
selector:
"Slider[ngModel],Slider[formControlName],Slider[formControl]," +
"slider[ngModel],slider[formControlName],slider[formControl]",
providers: [NUMBER_VALUE_ACCESSOR],
host: {
"(valueChange)": "onChange($event.value)",
},
})
export class NumberValueAccessor extends BaseValueAccessor<Slider> { // tslint:disable-line:directive-class-suffix
constructor(elementRef: ElementRef) {
开发者ID:NathanWalker,项目名称:nativescript-angular,代码行数:31,代码来源:number-value-accessor.ts
示例7: expect
.then((compFixture) => {
let nestedChildCompEl = compFixture.debugElement.children[0].children[0];
let nestedChildComp: NestedChildComp = nestedChildCompEl.componentInstance;
expect(nestedChildComp.cfr.resolveComponentFactory(ChildComp).componentType)
.toBe(ChildComp);
expect(() => nestedChildComp.cfr.resolveComponentFactory(NestedChildComp))
.toThrow(new NoComponentFactoryError(NestedChildComp));
async.done();
});
}));
});
}
var DIRECTIVES: any[] = [
forwardRef(() => NestedChildComp),
forwardRef(() => ChildComp),
forwardRef(() => MainComp),
];
@Component({selector: 'nested', directives: DIRECTIVES, template: ''})
class NestedChildComp {
constructor(public cfr: ComponentFactoryResolver) {}
}
@Component({selector: 'child', precompile: [NestedChildComp], directives: DIRECTIVES, template: ''})
class ChildComp {
constructor(public cfr: ComponentFactoryResolver) {}
}
@Component({
开发者ID:HongXG,项目名称:angular,代码行数:31,代码来源:precompile_integration_spec.ts
示例8: forwardRef
import { Directive, Input, forwardRef, OnInit } from '@angular/core';
import { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';
import { CustomValidators } from '../';
const EQUAL_TO_VALIDATOR: any = {
provide: NG_VALIDATORS,
useExisting: forwardRef(() => EqualToValidator),
multi: true
};
@Directive({
selector: '[equalTo][formControlName],[equalTo][formControl],[equalTo][ngModel]',
providers: [EQUAL_TO_VALIDATOR]
})
export class EqualToValidator implements Validator, OnInit {
@Input() equalTo: AbstractControl;
private validator: ValidatorFn;
ngOnInit() {
this.validator = CustomValidators.equalTo(this.equalTo);
}
validate(c: AbstractControl): {[key: string]: any} {
return this.validator(c);
}
}
开发者ID:Cloudhubke,项目名称:ng2-validation,代码行数:28,代码来源:equal-to.ts
示例9: validate
*
* @stable
*/
export interface Validator {
validate(c: AbstractControl): ValidationErrors|null;
registerOnValidatorChange?(fn: () => void): void;
}
/** @experimental */
export interface AsyncValidator extends Validator {
validate(c: AbstractControl): Promise<ValidationErrors|null>|Observable<ValidationErrors|null>;
}
export const REQUIRED_VALIDATOR: Provider = {
provide: NG_VALIDATORS,
useExisting: forwardRef(() => RequiredValidator),
multi: true
};
export const CHECKBOX_REQUIRED_VALIDATOR: Provider = {
provide: NG_VALIDATORS,
useExisting: forwardRef(() => CheckboxRequiredValidator),
multi: true
};
/**
* A Directive that adds the `required` validator to any controls marked with the
* `required` attribute, via the {@link NG_VALIDATORS} binding.
*
* ### Example
开发者ID:diestrin,项目名称:angular,代码行数:31,代码来源:validators.ts
注:本文中的@angular/core.forwardRef函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论