@angular/core#SkipSelf TypeScript Examples

The following examples show how to use @angular/core#SkipSelf. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: core.module.ts    From enterprise-ng-2020-workshop with MIT License 6 votes vote down vote up
constructor(
    @Optional()
    @SkipSelf()
    parentModule: CoreModule,
    faIconLibrary: FaIconLibrary
  ) {
    if (parentModule) {
      throw new Error('CoreModule is already loaded. Import only in AppModule');
    }
    faIconLibrary.addIcons(
      faCog,
      faBars,
      faRocket,
      faPowerOff,
      faUserCircle,
      faPlayCircle,
      faGithub,
      faMediumM,
      faTwitter,
      faInstagram,
      faYoutube
    );
  }
Example #2
Source File: api.module.ts    From geonetwork-ui with GNU General Public License v2.0 6 votes vote down vote up
constructor(
    @Optional() @SkipSelf() parentModule: ApiModule,
    @Optional() http: HttpClient
  ) {
    if (parentModule) {
      throw new Error(
        'ApiModule is already loaded. Import in your base AppModule only.'
      )
    }
    if (!http) {
      throw new Error(
        'You need to import the HttpClientModule in your AppModule! \n' +
          'See also https://github.com/angular/angular/issues/20575'
      )
    }
  }
Example #3
Source File: api.module.ts    From geonetwork-ui with GNU General Public License v2.0 6 votes vote down vote up
constructor(
    @Optional() @SkipSelf() parentModule: ApiModule,
    @Optional() http: HttpClient
  ) {
    if (parentModule) {
      throw new Error(
        'ApiModule is already loaded. Import in your base AppModule only.'
      )
    }
    if (!http) {
      throw new Error(
        'You need to import the HttpClientModule in your AppModule! \n' +
          'See also https://github.com/angular/angular/issues/20575'
      )
    }
  }
Example #4
Source File: api.module.ts    From RoboScan with GNU General Public License v3.0 6 votes vote down vote up
constructor( @Optional() @SkipSelf() parentModule: ApiModule,
                 @Optional() http: HttpClient) {
        if (parentModule) {
            throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
        }
        if (!http) {
            throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
            'See also https://github.com/angular/angular/issues/20575');
        }
    }
Example #5
Source File: router.component.ts    From router with MIT License 6 votes vote down vote up
// support multiple "routers"
  // router (base /)
  // blog(.*?)
  // router (base /blog)
  // post1(blog/post1/(.*?)
  // post2
  // post3

  constructor(
    private router: Router,
    @SkipSelf() @Optional() public parentRouterComponent: RouterComponent
  ) {}
Example #6
Source File: tab-context.service.ts    From alauda-ui with MIT License 6 votes vote down vote up
constructor(
    @Optional()
    @SkipSelf()
    readonly _parent: TabContextService,
  ) {
    this.active$ = (
      _parent
        ? combineLatest([_parent.active$, this.active$$]).pipe(
            map(([a, b]) => a && b),
          )
        : this.active$$
    ).pipe(distinctUntilChanged());
  }
Example #7
Source File: form-tree-node.service.ts    From open-source with MIT License 6 votes vote down vote up
constructor(
    private readonly formFactory: DynFormFactory,
    private readonly formHandlers: DynFormHandlers,
    private readonly logger: DynLogger,
    @Optional() @Inject(DYN_MODE)
    private readonly _mode$: BehaviorSubject<DynControlMode>,
    // parent node should be set for all except the root
    @Optional() @SkipSelf()
    public readonly parent: DynFormTreeNode<any>,
  ) {}
Example #8
Source File: icon-register.service.ts    From alauda-ui with MIT License 6 votes vote down vote up
ICON_REGISTER_SERVICE_PROVIDER = {
  provide: IconRegisterService,
  deps: [
    [new Optional(), new SkipSelf(), IconRegisterService],
    [new Optional(), DOCUMENT],
    [new Optional(), HttpClient],
  ],
  useFactory: ICON_REGISTER_PROVIDER_FACTORY,
}
Example #9
Source File: api.module.ts    From barista with Apache License 2.0 6 votes vote down vote up
constructor( @Optional() @SkipSelf() parentModule: ApiModule,
                 @Optional() http: HttpClient) {
        if (parentModule) {
            throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
        }
        if (!http) {
            throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
            'See also https://github.com/angular/angular/issues/20575');
        }
    }
Example #10
Source File: toggle.component.ts    From canopy with Apache License 2.0 6 votes vote down vote up
constructor(
    @Self() @Optional() public control: NgControl,
    @Optional()
    @Inject(forwardRef(() => LgCheckboxGroupComponent))
    private checkboxGroup: LgCheckboxGroupComponent,
    private domService: LgDomService,
    private errorState: LgErrorStateMatcher,
    @Optional()
    @Host()
    @SkipSelf()
    private controlContainer: FormGroupDirective,
    private hostElement: ElementRef,
  ) {
    this.selectorVariant = this.hostElement.nativeElement.tagName
      .split('-')[1]
      .toLowerCase();

    if (this.checkboxGroup) {
      return;
    }

    if (this.control != null) {
      this.control.valueAccessor = this;
    }
  }
Example #11
Source File: radio-group.component.ts    From canopy with Apache License 2.0 6 votes vote down vote up
constructor(
    @Self() @Optional() private control: NgControl,
    private errorState: LgErrorStateMatcher,
    @Optional()
    @Host()
    @SkipSelf()
    private controlContainer: FormGroupDirective,
    private domService: LgDomService,
    private hostElement: ElementRef,
    private renderer: Renderer2,
  ) {
    this.variant = this.hostElement.nativeElement.tagName
      .split('-')[1]
      .toLowerCase() as RadioVariant;

    if (this.control != null) {
      this.control.valueAccessor = this;
    }
  }
Example #12
Source File: radio-button.component.ts    From canopy with Apache License 2.0 6 votes vote down vote up
constructor(
    @Self() @Optional() public control: NgControl,
    @Inject(forwardRef(() => LgRadioGroupComponent))
    private radioGroup: LgRadioGroupComponent,
    private errorState: LgErrorStateMatcher,
    @Optional()
    @Host()
    @SkipSelf()
    private controlContainer: FormGroupDirective,
    private renderer: Renderer2,
    private hostElement: ElementRef,
    private domService: LgDomService,
  ) {}
Example #13
Source File: checkbox-group.component.ts    From canopy with Apache License 2.0 6 votes vote down vote up
constructor(
    @Self() @Optional() private control: NgControl,
    private errorState: LgErrorStateMatcher,
    @Optional()
    @Host()
    @SkipSelf()
    private controlContainer: FormGroupDirective,
    private domService: LgDomService,
    private renderer: Renderer2,
    private hostElement: ElementRef,
  ) {
    this.variant = this.hostElement.nativeElement.tagName
      .split('-')[1]
      .toLowerCase() as CheckboxGroupVariant;

    if (this.control != null) {
      this.control.valueAccessor = this;
    }
  }
Example #14
Source File: accordion-item.component.ts    From canopy with Apache License 2.0 6 votes vote down vote up
constructor(
    @Optional() @SkipSelf() @Inject(LG_ACCORDION) public accordion: LgAccordionComponent,
    private selectionDispatcher: UniqueSelectionDispatcher,
    private cdr: ChangeDetectorRef,
  ) {
    this._removeSingleItemSelectionListener = selectionDispatcher.listen(
      (id: string, accordionId: string) => {
        if (
          accordion &&
          !accordion.multi &&
          accordion.id === accordionId &&
          this._id !== id
        ) {
          this.isActive = false;
          this.accordionPanelHeading.isActive = false;

          this.closed.emit();
          this.cdr.markForCheck();
        }
      },
    );
  }
Example #15
Source File: core.module.ts    From youpez-admin with MIT License 5 votes vote down vote up
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    throwIfAlreadyLoaded(parentModule, 'CoreModule')
  }
Example #16
Source File: bar-drag.ts    From ngx-gantt with MIT License 5 votes vote down vote up
constructor(
        private dragDrop: DragDrop,
        private dom: GanttDomService,
        private dragContainer: GanttDragContainer,
        @SkipSelf() private root: NgxGanttRootComponent
    ) {}
Example #17
Source File: core.module.ts    From digital-bank-ui with Mozilla Public License 2.0 5 votes vote down vote up
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    throwIfAlreadyLoaded(parentModule, 'CoreModule');
  }
Example #18
Source File: factory.component.ts    From open-source with MIT License 5 votes vote down vote up
private createFrom(config: DynBaseConfig): void {
    try {
      const control = this.registry.get(config.control);
      const factory = this.resolver.resolveComponentFactory(control.component);

      const newInjectionLayer = Injector.create({
        providers: [
          // new form-hierarchy sublevel
          // DynControls has its own DynFormTreeNode
          {
            provide: DynFormTreeNode,
            useClass: DynFormTreeNode,
            deps: [ // FIXME added for Stackblitz
              DynFormFactory,
              DynFormHandlers,
              DynLogger,
              DYN_MODE,
              [new SkipSelf(), DynFormTreeNode],
            ],
          },
          config?.debug ? [
            {
              provide: DYN_LOG_LEVEL,
              useValue: config.debug,
            },
            DynLogDriver,
            DynLogger,
          ] : [],
        ],
        parent: this._injector,
      });

      this.component = this.container.createComponent<AbstractDynControl>(
        factory,
        undefined,
        newInjectionLayer,
      );
      this.component.instance.config = config;
      this.component.instance.node.setIndex(this.index);
      // we let the corresponding DynFormTreeNode to initialize the control
      // and register itself in the Form Tree in the lifecycle methods

      this.component.hostView.detectChanges();

      this.logger.controlInstantiated(this.component.instance.node, {
        control: config.control,
        name: config.name,
        controls: config.controls?.length || 0,
      });

      // listen control.visibility$
      this.component.instance.visibility$
        .pipe(
          startWith(config.visibility || 'VISIBLE'),
          takeUntil(this.component.instance.onDestroy$),
        )
        .subscribe((visibility) => {
          if (this.visibility !== visibility) {
            this.visibility = visibility;
            this.ref.markForCheck();
          }
        });

    } catch(e) {
      // log any error happening in the control instantiation
      console.error(e);
    }
  }
Example #19
Source File: core.module.ts    From nodejs-angular-typescript-boilerplate with Apache License 2.0 5 votes vote down vote up
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    if (parentModule) {
      throw new Error(
        `${parentModule} has already been loaded. Import Core module in the AppModule only.`
      );
    }
  }
Example #20
Source File: core.module.ts    From IntelOwl-ng with GNU Affero General Public License v3.0 5 votes vote down vote up
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    throwIfAlreadyLoaded(parentModule, 'CoreModule');
  }
Example #21
Source File: core.module.ts    From ng-ant-admin with MIT License 5 votes vote down vote up
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    if (parentModule) {
      throw new Error(`CoreModule has already been loaded. Import Core modules in the AppModule only.`);
    }
  }
Example #22
Source File: core.module.ts    From data-annotator-for-machine-learning with Apache License 2.0 5 votes vote down vote up
constructor(@Optional() @SkipSelf() core: CoreModule) {
    if (core) {
      throw new Error('You should import core module only in the root module');
    }
  }
Example #23
Source File: core.module.ts    From ng-devui-admin with MIT License 5 votes vote down vote up
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    throwIfAlreadyLoaded(parentModule, 'CoreModule');
  }
Example #24
Source File: core.module.ts    From dating-client with MIT License 5 votes vote down vote up
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    if (parentModule) {
      throw new Error('CoreModule is already loaded. Import it in the AppModule only!');
    }
  }
Example #25
Source File: background-provider-inner.component.ts    From halstack-angular with Apache License 2.0 5 votes vote down vote up
constructor( public element:ElementRef,
    @Optional() @SkipSelf() public bgProviderService: BackgroundProviderService
  ) {}
Example #26
Source File: core.module.ts    From angular-padroes-e-boas-praticas with MIT License 5 votes vote down vote up
constructor(
    @Optional() @SkipSelf() parentModule: CoreModule
  ) {

    if (parentModule) {
      throw new Error('CoreModule já foi instanciado. Importe-o somente em AppModule.');
    }
  }
Example #27
Source File: tooltip-intl.ts    From alauda-ui with MIT License 5 votes vote down vote up
TOOLTIP_COPY_INTL_INTL_PROVIDER = {
  // If there is already an CodeEditorIntl available, use that. Otherwise, provide a new one.
  provide: TooltipCopyIntl,
  deps: [[new Optional(), new SkipSelf(), TooltipCopyIntl]],
  useFactory: TOOLTIP_COPY_INTL_PROVIDER_FACTORY,
}
Example #28
Source File: paginator-intl.ts    From alauda-ui with MIT License 5 votes vote down vote up
PAGINATOR_INTL_PROVIDER = {
  // If there is already an PaginatorIntl available, use that. Otherwise, provide a new one.
  provide: PaginatorIntl,
  deps: [[new Optional(), new SkipSelf(), PaginatorIntl]],
  useFactory: PAGINATOR_INTL_PROVIDER_FACTORY,
}
Example #29
Source File: accordion.component.ts    From alauda-ui with MIT License 5 votes vote down vote up
constructor(
    @SkipSelf()
    @Optional()
    public parent: AccordionComponent,
  ) {
    super();
    this.depth = parent ? parent.depth + 1 : 0;
  }