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
export function equalArraysOrString(a: string | string[], b: string | string[]) { | |
if (Array.isArray(a) && Array.isArray(b)) { | |
if (a.length != b.length) return false; | |
return a.every(aItem => b.indexOf(aItem) > -1); | |
} else { | |
return a === b; | |
} | |
} |
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
setUpLocationSync(ngUpgrade: UpgradeModule, urlType: "path" | "hash" = 'path') |
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
constructor(private router: Router) { | |
this.router.events.subscribe( (event: RouterEvent) => console.log(event)) | |
} |
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
private applyRedirectCreatreUrlTree( | |
redirectTo: string, urlTree: UrlTree, segments: UrlSegment[], | |
posParams: {[k: string]: UrlSegment}): UrlTree { | |
const newRoot = this.createSegmentGroup(redirectTo, urlTree.root, segments, posParams); | |
return new UrlTree( | |
newRoot, this.createQueryParams(urlTree.queryParams, this.urlTree.queryParams), | |
urlTree.fragment); | |
} |
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
//Inside index.html | |
<script src="https://unpkg.com/@nishugoel/prod-card@0.0.5/main.js"></script> | |
//Use the custom element in the App.js file | |
<prod-card username='Enter your name' password='Enter new password' btnname='Sign in'></prod-card> |
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
{ | |
"name" : "@nishugoel/prod-card", | |
"version": "0.0.5" | |
} |
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
constructor(private injector: Injector) { | |
const customElement = createCustomElement(CustomElementDemoComponent, { injector }); | |
customElements.define('custom-element', customElement); | |
} |
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
//Inside NgModule | |
entryComponents: [CustomElementDemoComponent], | |
}) | |
export class FeatureModule { | |
constructor(private injector: Injector) { | |
} |
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
@Component({ | |
templateUrl: './custom-elements.component.html', | |
styleUrls: ['./custom-elements.component.scss'] | |
}) | |
export class ComponentName { | |
title = 'custom-elements-demo'; | |
} |
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
<section> | |
<div> | |
<slot></slot> //Content of the custom element gets placed here | |
</div> | |
</section> | |
// Custom Element | |
<my-element> | |
<button>Custom button</button> |