Last active
July 31, 2023 20:37
-
-
Save fourgates/703b0b58c3d9ef1db3e05f5cc2c6308e to your computer and use it in GitHub Desktop.
Revisions
-
fourgates revised this gist
Jul 31, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,8 @@ // sort a table! // // however, you can also just import the table or the table-sort directive if you wanted to! // // FYI -- this angular library gets built with the following cmd: `yarn build-lib && yarn pack-lib` // 1. export a group of components from an angular library / project / component -
fourgates created this gist
Jul 31, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ // This is a way to get best of both worlds of grouping component together // into "modules" (barrels) and using standalone components! // // using a "barrel" export you can group together angular components so you only need to // import one object // // a good use case for this is components that are dependent on each other or commonly used together // in this example we have a table and table-sort directive bc you almost always want to be able to // sort a table! // // however, you can also just import the table or the table-sort directive if you wanted to! // 1. export a group of components from an angular library / project / component @Directive({...standalone: true...}) export class OurTableSortByDirective { .. } @Component({...standalone: true...}) export class OurTableComponent {...} // 2. THIS IS THE BARREL! export const OUR_TABLE = [ OurTableComponent, OurTableSortByDirective ] as const; // 3. import the barrel into the client component! // some-example-component-with-tables.component.ts import { OUR_TABLE, } from 'our-ui-library'; ... @Component({ ... standalone: true, imports: [ ... OUR_TABLE, ... ], ... }) export class SearchTableComponent {...}