Created
October 19, 2019 18:25
-
-
Save muhammadawaisshaikh/8ace605d10342b9d543ad7586b0a98cf to your computer and use it in GitHub Desktop.
Deep Dive into Dependency Injection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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