I found that great package @angular/angular-flex and in the first moment everything was fine. Then I noticed that the default breakpoints differ to the breakpoints of Bootstrap4. But no problem: custom breakpoints.
But here is a problem: because the defined breakpoints are being ignored and I can't find a solution. Also the documentation is a bit confusing. Sometimes I saw imports from BREAKPOINT and the next time BREAKPOINTS where imported. What is correct now?
But this this not the fight. The fight is to get the code running and I hope that somebody can help me please. I'm using Angular 9 for my project.
The breakpoints are defined in: custom-breakpoints.ts
import { BREAKPOINT } from '@angular/flex-layout';
export const BS4_BREAKPOINTS = [
{ alias: 'xs', mediaQuery: 'screen and (max-width: 575px)' },
{ alias: 'sm', mediaQuery: 'screen and (min-width: 576px) and (max-width: 767px)' },
{ alias: 'md', mediaQuery: 'screen and (min-width: 768px) and (max-width: 991px)' },
{ alias: 'lg', mediaQuery: 'screen and (min-width: 992px) and (max-width: 1199px)' },
{ alias: 'xl', mediaQuery: 'screen and (min-width: 1200px) and (max-width: 5000px)' },
{ alias: 'lt-sm', mediaQuery: 'screen and (max-width: 575px)' },
{ alias: 'lt-md', mediaQuery: 'screen and (max-width: 767px)' },
{ alias: 'mdtest', mediaQuery: 'screen and (max-width: 767px)' },
{ alias: 'lt-lg', mediaQuery: 'screen and (max-width: 991px)' },
{ alias: 'lt-xl', mediaQuery: 'screen and (max-width: 1199px)' },
{ alias: 'gt-xs', mediaQuery: 'screen and (min-width: 576px)' },
{ alias: 'gt-sm', mediaQuery: 'screen and (min-width: 768px)' },
{ alias: 'gt-md', mediaQuery: 'screen and (min-width: 992px)' },
{ alias: 'gt-lg', mediaQuery: 'screen and (min-width: 1200px)' },
];
export const CustomBreakPointsProvider = {
provide: BREAKPOINT,
useValue: BS4_BREAKPOINTS,
multi: true,
};
and the module declares:
import { CustomBreakPointsProvider } from './services';
import { BS4_BREAKPOINTS } from './services';
@NgModule({
imports: [
CommonModule,
FormsModule,
FlexLayoutModule.withConfig({ disableDefaultBps: true }, BS4_BREAKPOINTS),
...
],
declarations: [
...
],
providers: [
CustomBreakPointsProvider, // Adds breakpoints mediaQueries
],
})
Then I try to apply the breakpoint in the HTML, like:
<div class="col-md-6" [ngClass.mdtest]="{'alert alert-info': true}">
...
</div>
The result is that ngClass.mdtest is being ignored. But what I'm doing wrong?