How to use the @angular/core.Directive function in @angular/core

To help you get started, we’ve selected a few @angular/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Alfresco / alfresco-ng2-components / lib / core / datatable / directives / no-content-template.directive.ts View on Github external
*     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { AfterContentInit, ContentChild, Directive, TemplateRef } from '@angular/core';
import { DataTableComponent } from '../components/datatable/datatable.component';

/**
 * Directive selectors without adf- prefix will be deprecated on 3.0.0
 */
@Directive({
    selector: 'adf-no-content-template, no-content-template'
})
export class NoContentTemplateDirective implements AfterContentInit {

    @ContentChild(TemplateRef)
    template: any;

    constructor(private dataTable: DataTableComponent) {
    }

    ngAfterContentInit() {
        if (this.dataTable) {
            this.dataTable.noContentTemplate = this.template;
        }
    }
}
github dancancro / great-big-example-application / src / main / webapp / app / shared / ba / ba-card / ba-card-blur.directive.ts View on Github external
import { Directive, ElementRef, HostListener, HostBinding } from '@angular/core';
import { BaThemeConfigProvider } from '../../../shared/theme';

import { BaCardBlurHelper } from './ba-card-blur-helper.service';
import { BgMetrics } from './bg-metrics';

@Directive({
  selector: '[baCardBlur]',
  providers: [BaCardBlurHelper]
})
export class BaCardBlurDirective {

  @HostBinding('class.card-blur') isEnabled = false;

  private _bodyBgSize: BgMetrics;

  constructor(private _baConfig: BaThemeConfigProvider, private _baCardBlurHelper: BaCardBlurHelper, private _el: ElementRef) {
    if (this._isEnabled()) {
      this._baCardBlurHelper.init();
      this._getBodyImageSizesOnBgLoad();
      this._recalculateCardStylesOnBgLoad();

      this.isEnabled = true;
github wpcfan / taskmgr / src / app / directives / scroll-monitor.directive.ts View on Github external
import { Directive, HostListener } from '@angular/core';

@Directive({
  selector: '[appScrollMonitor]'
})
export class ScrollMonitorDirective {

  @HostListener('scroll', ['$event.target'])
  onScroll({scrollHeight, clientHeight, scrollTop}: {scrollHeight: number; clientHeight: number; scrollTop: number}) {
    const limit = scrollHeight - clientHeight;
    console.log(scrollTop, limit);
  }
}
github infra-geo-ouverte / igo2-lib / packages / context / src / lib / share-map / share-map / share-map-binding.directive.ts View on Github external
import { Directive, Self, OnInit, Optional } from '@angular/core';

import { LayerListService } from '@igo2/geo';
import { ShareMapComponent } from './share-map.component';
import { RouteService } from '@igo2/core';

@Directive({
  selector: '[igoShareMapBinding]'
})
export class ShareMapBindingDirective implements OnInit {
  private component: ShareMapComponent;

  constructor(
    @Self() component: ShareMapComponent,
    private layerListService: LayerListService,
    @Optional() private route: RouteService
  ) {
    this.component = component;
  }

  ngOnInit() {
    this.initRoutes();
  }
github rabix / composer / src / app / ui / context / context.directive.ts View on Github external
import {Directive, HostListener, Input, ViewContainerRef} from "@angular/core";
import {MenuItem} from "../menu/menu-item";
import {ContextService} from "./context.service";

@Directive({
    selector: "[ct-context]"
})
export class ContextDirective {

    @Input("ct-context")
    private contextMenuItems: MenuItem[];

    constructor(private context: ContextService,
                private viewContainer: ViewContainerRef) {
    }

    @HostListener("contextmenu", ["$event"])
    private onRightClick(event: MouseEvent) {
        event.preventDefault();
        if (!this.contextMenuItems) {
            return;
github ionic-team / ionic / src / components / refresher / refresher.ts View on Github external
*
 * ## Further Customizing Refresher Content
 *
 * The `ion-refresher` component holds the refresh logic.
 * It requires a child component in order to display the content.
 * Ionic uses `ion-refresher-content` by default. This component
 * displays the refresher and changes the look depending
 * on the refresher's state. Separating these components
 * allows developers to create their own refresher content
 * components. You could replace our default content with
 * custom SVG or CSS animations.
 *
 * @demo /docs/demos/src/refresher/
 *
 */
@Directive({
  selector: 'ion-refresher',
  host: {
    '[class.refresher-active]': 'state !== "inactive"',
    '[style.top]': '_top'
  }
})
export class Refresher {
  _appliedStyles: boolean = false;
  _didStart: boolean;
  _lastCheck: number = 0;
  _isEnabled: boolean = true;
  _gesture: GestureDelegate;
  _events: UIEventManager;
  _pointerEvents: PointerEvents;
  _top: string = '';
github Sunbird-Ed / SunbirdEd-portal / src / app / client / src / app / modules / core / directives / stickyheader.directive.ts View on Github external
import { environment } from '@sunbird/environment';
import { animate, AnimationBuilder, AnimationMetadata, AnimationPlayer, style } from '@angular/animations';

import { AfterViewInit, Directive, ElementRef, Inject, OnDestroy, NgZone, ChangeDetectorRef, } from '@angular/core';
import { fromEvent, Subject } from 'rxjs';
import { distinctUntilChanged, filter, map, pairwise, share, throttleTime, takeUntil, tap } from 'rxjs/operators';

enum Direction {
  Up = 'Up',
  Down = 'Down',
  None = 'None'
}

/** @dynamic */
@Directive({
  selector: '[appStickyHeader]'
})
export class StickyHeaderDirective implements AfterViewInit, OnDestroy {
  player: AnimationPlayer;
  public unsubscribe = new Subject();
  isOffline: boolean = environment.isOffline;

  set show(show: boolean) {
    if (this.player) {
      this.player.destroy();
    }

    const metadata = show ? this.fadeIn() : this.fadeOut();

    const factory = this.builder.build(metadata);
    const player = factory.create(this.el.nativeElement);
github AnBauer / ngx-lightning / projects / ngx-lightning / src / lib / datatables / heading.ts View on Github external
import { Directive, TemplateRef } from '@angular/core';

@Directive({selector: '[nglDatatableHeading]'})
export class NglDatatableHeadingTemplateDirective {
  constructor(public templateRef: TemplateRef) {
  }
}
github UXAspects / UXAspects / src / hybrid / components / sankey-chart / sankey.component.ts View on Github external
import { Directive, ElementRef, Injector, Input } from '@angular/core';
import { UpgradeComponent } from '@angular/upgrade/static';

@Directive({
    selector: 'sankey'
})
export class SankeyNg1Component extends UpgradeComponent {

    @Input() chartSize: any;
    @Input() chartData: any;
    @Input() options: any;
    @Input() click: any;

    constructor(elementRef: ElementRef, injector: Injector) {
        super('uxSankeyNg1', elementRef, injector);
    }
}
github AnBauer / ngx-lightning / projects / ngx-lightning / src / lib / lookups / scope-item.ts View on Github external
import { Directive, EventEmitter, Input, Output, TemplateRef } from '@angular/core';

@Directive({selector: '[nglPolymorphicItem]'})
export class NglLookupScopeItem {
  @Input() scopes: any[] = [];

  @Output() scopeChange = new EventEmitter();

  constructor(public templateRef: TemplateRef) {}
}