Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizGeneral Tech Bugs & Fixes 3 years ago
User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.
You can initialize a parameter of a class with null then it will not give you error on initialization of new Object
EXAMPLE:
export class HttpWrapper {
private _url: string;
private _port: number;
private _api: string;
private _headers: Map<string, string>;
constructor(private httpServie: HttpServiceProvider = null, url: string, port: number, api: string){
this.url = url;
this.port = port;
this.api = api;
}
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
manpreet
Best Answer
3 years ago
I’m new to Inonic/Angular.
My question is, I have this class that I’ve created which uses DI:
When I want to create a new instance of this class I need to provide ‘HttpServiceProvider’ to the constructor. What is the right way to initiate new object of this kind? (without providing the ‘HttpServiceProvider’).