I want to use angular class and service mechanism for my project's scalable structure.
I have created one component, named : car I have created one class, named : wheel I have created one service, named : rotate
Now according to my flow.
car component is look like this :
import { wheel } from './Class/wheel';
@Component({
selector: 'app-car',
templateUrl: './car.page.html',
styleUrls: ['./car.page.scss'],
})
export class car implements OnInit {
car:any = [];
wheelSection: Wheel;
constructor(){
}
ngOnInit() {
this.WheelSection = new Wheel(); // I don't want to pass any parameter here..
this.car.push(WheelSection);
}
}
Wheel class is look like this :
import { Rotate } from '../Service/Rotate.service';
export class Wheel {
wheelRing:any;
WheelRotate:any;
constructor(private rotateService: Rotate){
this.WheelRotate = rotateService.rotate();
}
}
I have tried this code and it is giving me error at the wheel class's initialization in car component's regarding that 1 argument required but you send 0 argument...
Here in above two code. Wheel class constructor needs one parameter for initialize that class in car component. but I don't want to pass any parameter into that wheel class's constructor.
Is there any way to do this kind of flow for initialize class object without passing provider parameter into constructor ?
The main reason is not passing that into constructor is that there are many services used by various classes and all it's import are in base main component is some kind of weird stuff.
Please help me if any one have a solution about this.