Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muhammadawaisshaikh/8ace605d10342b9d543ad7586b0a98cf to your computer and use it in GitHub Desktop.
Save muhammadawaisshaikh/8ace605d10342b9d543ad7586b0a98cf to your computer and use it in GitHub Desktop.
Deep Dive into Dependency Injection
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-dependency-injection',
templateUrl: './dependency-injection.component.html',
styleUrls: ['./dependency-injection.component.scss']
})
export class DependencyInjectionComponent implements OnInit {
// Car
// |
// |--Engine
// | |
// | |--Pistons
// |
// |--Wheels
action: any;
constructor() { }
ngOnInit() {
this.car();
}
pistons(){
this.action = {
work: "The pistons fire up."
}
console.log(this.action);
}
engine() {
this.pistons();
this.action = {
work: "The engine goes vroom vroom."
}
console.log(this.action);
}
wheels() {
this.action = {
work: "The wheels go 'round and 'round."
}
console.log(this.action);
}
car() {
this.engine();
this.wheels();
this.action = {
work: "The car drives by."
}
console.log(this.action);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment