Home > database >  Angular Material: do I need to import every card component
Angular Material: do I need to import every card component

Time:11-09

if I want to use a Material Card components.

'mat-card-actions' is not a known element:
'mat-card-content' is not a known element:
'mat-card-title' is not a known element:
'mat-card-header' is not a known element:
'mat-card' is not a known element:

do I need to import them one by one?

CodePudding user response:

You only need to import the module, that's it.

import {MatCardModule} from '@angular/material/card'; 

CodePudding user response:

Yes, for the tree-shaking of Angular. By the way, you can just create an array in one file and import the array, then spread it into the imports:

FILE 1-- -- -- -- -- -- -
import {
  lib
} from './file'

@NgModule()
export class App {
  ...
  ...
  imports: [
    ...lib
  ]
}



FILE 2-- -- -- -- -- -- -
import { ...
} from '...'

export const lib = [All_Components]
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

  • Related