Unprepared (in promise): Error: no provider for the string - angular2

I am new to angular2 and I am stuck with this error. I have a class like this

@Injectable()
export class VehicleDetails {
    constructor(private policynumber: string, private vinnumber: string) {
        this.policyNumber = policynumber,
            this.vinNumber = vinnumber
    }
    policyNumber: string;
    vinNumber: string;
}

and another class like this

export class Policy {
    constructor() {
    }
    emailAddress: string;
    vehicleDetails: VehicleDetails[]
}

I have imported my class into modules like this

import { Policy } from './models/Policy';
import { VehicleDetails } from './models/VehicleDetails';
@NgModule({
  declarations: [
    LienholderComponent,
    AppComponent,
    PolicyVehicleComponent
  ],
  imports: [
    RouterModule.forRoot(
      APP_ROUTES,
      { enableTracing: true } // <-- debugging purposes only
    ),
    BrowserModule,
    FileUploadModule,
    ReactiveFormsModule,
    HttpModule
  ],
  providers: [Policy, VehicleDetails],
  bootstrap: [AppComponent]
})
export class AppModule { }

when I comment on my constructor in the VehicleDetails class, everything works fine, but when I use contructor, I start getting this error. how to solve this error, I have two string parameters in the constructor, because I would like to add values ​​dynamically.

my mistake is this

enter image description here

What I want to build a VehicleDetails class is how it is

this.policy.emailAddress='email@test.com';
    this.policy.vehicleDetails.push(new VehicleDetails('valueA1','valueA2'));
    this.policy.vehicleDetails.push(new VehicleDetails('valueB1','valueB2'));
    this.policy.vehicleDetails.push(new VehicleDetails('valueC1','valueC2'));

So, I get the value dynamically, and I want to bind the values ​​to the model as described in the code above

+6
2

DI VehicleDetails, , private policynumber: string, private vinnumber: string

, @Inject()

constructor(@Inject('policy') private policynumber: string, @Inject('vin') private vinnumber: string) {

,

providers: [Policy, VehicleDetails, {provide: 'policy', useValue: 'abc'}, {provide: 'vin', useValue: 'def'}],
+6

@Injectable . VehicleDetails :

export class VehicleDetails {
    constructor(policynumber: string, vinnumber: string) {
        this.policyNumber = policynumber,
            this.vinNumber = vinnumber
    }
    policyNumber: string;
    vinNumber: string;
}

VehicleDetails AppModule.

+1

All Articles