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