Skip to content

Commit

Permalink
feat(alert)): migrated to standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
lexasq committed Jul 16, 2024
1 parent 24bfd94 commit c8a4b16
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion libs/doc-pages/alerts/src/lib/alerts.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export { AlertsSectionComponent } from './alerts-section.component';
...DEMO_COMPONENTS
],
imports: [
AlertModule.forRoot(),
AlertModule,
CommonModule,
DocsModule,
RouterModule.forChild(routes)
Expand Down
2 changes: 1 addition & 1 deletion libs/doc-pages/alerts/src/lib/docs/usage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AlertModule } from 'ngx-bootstrap/alert';

@NgModule({
imports: [AlertModule.forRoot(),...]
imports: [AlertModule,...]
})
export class AppModule(){}
9 changes: 6 additions & 3 deletions src/alert/alert.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import {
} from '@angular/core';
import { AlertConfig } from './alert.config';
import { OnChange } from 'ngx-bootstrap/utils';
import { NgIf, NgClass } from '@angular/common';

@Component({
selector: 'alert,bs-alert',
templateUrl: './alert.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
selector: 'alert,bs-alert',
templateUrl: './alert.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [NgIf, NgClass]
})
export class AlertComponent implements OnInit {
/** Alert type.
Expand Down
12 changes: 3 additions & 9 deletions src/alert/alert.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { CommonModule } from '@angular/common';
import { NgModule, ModuleWithProviders } from '@angular/core';
import { NgModule } from '@angular/core';
import { AlertComponent } from './alert.component';

@NgModule({
imports: [CommonModule],
declarations: [AlertComponent],
imports: [AlertComponent],
exports: [AlertComponent]
})
export class AlertModule {
static forRoot(): ModuleWithProviders<AlertModule> {
return { ngModule: AlertModule, providers: [] };
}
}
export class AlertModule {}
10 changes: 6 additions & 4 deletions src/alert/testing/alert.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AlertComponent, AlertConfig, AlertModule } from '../index';

@Component({selector: 'alert-test', template: ''})
@Component({
selector: 'alert-test', template: '',
standalone: true
})
class TestAlertComponent extends AlertComponent {
constructor(config: AlertConfig, changeDetection: ChangeDetectorRef) {
super(config, changeDetection);
Expand All @@ -25,9 +28,8 @@ describe('Component: Alert', () => {

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [TestAlertComponent],
imports: [AlertModule.forRoot()]
});
imports: [AlertModule, TestAlertComponent]
});
TestBed.overrideComponent(TestAlertComponent, {
set: {template: overTemplate}
});
Expand Down

0 comments on commit c8a4b16

Please sign in to comment.