# Angular

DynamicMapper provides mini library for basic integration with [Angular](https://github.com/angular/angular) framework.

### Install

```bash
npm i @dynamic-mapper/angular --save
```

### Import MapperModule and profile providers

Add your mapping profiles via `MapperModule.withProviders`.

```typescript
import { MapperModule } from '@dynamic-mapper/angular';

@NgModule({
    imports: [
        MapperModule.withProfiles([CustomerProfile, OrderProfile])
    ]
})
export class AppModule {}
```

### Inject mapper service

Inject mapper service from `@dynamic-mapper/angular` package. This mapper instance has configured all registered profiles from `MAPPING_PROFILE` provider.

```typescript
import { Mapper } from '@dynamic-mapper/angular';

@Injectable()
export class CustomerService {
    constructor(private readonly mapper: Mapper) {}
    
    toDto(customer: Customer) {
        return this.mapper.map(CustomerProfile.DomainToDto, customer);
    }
}
```
