|
@ -4,16 +4,24 @@ import { FormsModule } from '@angular/forms'; |
|
|
|
|
|
|
|
|
import { AppComponent } from './app.component'; |
|
|
import { AppComponent } from './app.component'; |
|
|
import { OrderService } from './order.service'; |
|
|
import { OrderService } from './order.service'; |
|
|
import { OrderDiscountService } from './order-discount.service'; |
|
|
|
|
|
|
|
|
import { OrderAnniversaryService } from './order-anniversary.service'; |
|
|
|
|
|
|
|
|
@NgModule({ |
|
|
@NgModule({ |
|
|
imports: [BrowserModule, FormsModule], |
|
|
imports: [BrowserModule, FormsModule], |
|
|
declarations: [AppComponent], |
|
|
declarations: [AppComponent], |
|
|
providers: [{ |
|
|
|
|
|
provide: OrderService, |
|
|
|
|
|
useValue:{computeTotal:()=>100}, |
|
|
|
|
|
},], |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
providers: [ |
|
|
|
|
|
{ |
|
|
|
|
|
provide: OrderService, |
|
|
|
|
|
useFactory: () => { |
|
|
|
|
|
const today = new Date(2020, 9, 3); |
|
|
|
|
|
if (today.getMonth() === 9) { |
|
|
|
|
|
return new OrderAnniversaryService(); |
|
|
|
|
|
} else { |
|
|
|
|
|
return new OrderService(); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
], |
|
|
bootstrap: [AppComponent], |
|
|
bootstrap: [AppComponent], |
|
|
}) |
|
|
}) |
|
|
export class AppModule {} |
|
|
export class AppModule {} |