-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61669a6
commit 74a6000
Showing
7 changed files
with
61 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
"error", | ||
{ | ||
"type": "attribute", | ||
"prefix": "app", | ||
"style": "camelCase" | ||
} | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-helpers-widget', | ||
template: ``, | ||
standalone: true, | ||
styleUrls: ['./styles.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class HelpersWidget {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Directive, OnChanges, Input, Renderer2, ElementRef, SimpleChanges } from '@angular/core'; | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: '[attributes]' | ||
}) | ||
export class AttributeDirective implements OnChanges { | ||
@Input() | ||
public attributes: { [key: string]: any }; | ||
|
||
constructor( | ||
private renderer: Renderer2, | ||
private elementRef: ElementRef | ||
) {} | ||
|
||
public ngOnChanges(changes: SimpleChanges): void { | ||
if (changes.attributes) { | ||
console.log('attributes>>>', this.attributes); | ||
for (const attributeName in this.attributes) { | ||
const attributeValue = this.attributes[attributeName]; | ||
if (attributeValue) { | ||
this.renderer.setAttribute(this.elementRef.nativeElement, attributeName, attributeValue); | ||
} else { | ||
this.renderer.removeAttribute(this.elementRef.nativeElement, attributeName); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './attribute.directive'; |