angular2-directives

Is it possible to create an angular material mat-table component with extra directives but still keep columns dynamic?

穿精又带淫゛_ 提交于 2021-01-07 06:22:38
问题 Is there a way to extend a mat-table that automatically includes the matSort directive (and other custom directives that interact with the columns, like filter) and still have the content inside hold the mat-sort-header directives? <mat-table [matSortActive]="sortActive" [matSortDirection]="sortDirection" matSort> <ng-content></ng-content> </mat-table> Here is an example: https://stackblitz.com/edit/angular-bxsavu. I've tried creating a component on its own that just puts <ng-content> inside

Is it possible to create an angular material mat-table component with extra directives but still keep columns dynamic?

跟風遠走 提交于 2021-01-07 06:21:18
问题 Is there a way to extend a mat-table that automatically includes the matSort directive (and other custom directives that interact with the columns, like filter) and still have the content inside hold the mat-sort-header directives? <mat-table [matSortActive]="sortActive" [matSortDirection]="sortDirection" matSort> <ng-content></ng-content> </mat-table> Here is an example: https://stackblitz.com/edit/angular-bxsavu. I've tried creating a component on its own that just puts <ng-content> inside

Angular: updateValueAndValidity from directive

随声附和 提交于 2021-01-02 06:40:26
问题 I have a directive that appends decimals, if the input value is a whole number, on blur. Below is the implementation. import { Directive, ElementRef, Input, OnInit, HostListener, forwardRef } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; @Directive({ selector: '[price]', providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => PriceDirective), multi: true } ] }) export class PriceDirective implements ControlValueAccessor {

Can I access child elements within a directive in Angular2?

隐身守侯 提交于 2020-12-29 05:33:32
问题 I'm trying to create a directive that accepts in input a icon property which would be the icon name. So the directive internally would try to find a span element where it will apply a class. I wonder if this is possible from within the directive applied to the parent. Or do I have to create a directive for the child too? Here's my HTML code: <div sfw-navbar-square sfw-navbar-icon> <span class="mdi mdi-magnify"></span> </div> Here's the directive itself: import { Directive, ElementRef,

Angular2 AfterViewChecked not firing on a directive when binding is complete on RC4

左心房为你撑大大i 提交于 2020-08-25 04:00:28
问题 I have an Angular 2 directive that makes the header (th) of a given table to remain fixed when the table is placed within a scrollable div. It resizes the column headers according to the size of the data on the cells, and vice-versa. It was working fine until Angular 2 RC1, but after I upgraded it to RC4 it stopped working. After a while I realized that the number of "AfterViewChecked" events triggered by the framework has been reduced, probably due to an issue that got fixed. The problem now

Apply attribute directive on component in Angular 4

孤街浪徒 提交于 2020-08-04 04:43:44
问题 I have created img-pop component which has @Input() bind property src. I have created authSrc directive which has @HostBinding() property src. @Component({ selector: 'img-pop', template: `<img [src]="src"/> <div *ngIf="isShow"> <----extra value-----> </div>` }) export class ImgPopOverComponent implements OnInit { @Input() private src; private isShow=false; @HostListener('mouseenter') onMouseEnter() { this.isShow= true; } @HostListener('mouseleave') onMouseLeave() { this.isShow= false; } } I

How to create a link to external URL in Angular 2

时光怂恿深爱的人放手 提交于 2020-07-18 03:46:20
问题 I am new to Angular. I am starting with ver. 2. I need to link to a file://... URL. I tried normal href : Note: app is a model object of the web which deals with applications. <a target="_blank" href="file://{{app.outputPath}}/index.html">no link here</a>. That doesn't work - the link is there, with correct URL, but Angular seems to block the event somehow. Why? So I've seen ng-href but that's for Angular 1.x. And there's no *ngHref from what I can tell. So this was just a naive try: <a

How to create a link to external URL in Angular 2

痴心易碎 提交于 2020-07-18 03:45:29
问题 I am new to Angular. I am starting with ver. 2. I need to link to a file://... URL. I tried normal href : Note: app is a model object of the web which deals with applications. <a target="_blank" href="file://{{app.outputPath}}/index.html">no link here</a>. That doesn't work - the link is there, with correct URL, but Angular seems to block the event somehow. Why? So I've seen ng-href but that's for Angular 1.x. And there's no *ngHref from what I can tell. So this was just a naive try: <a