Last active
September 11, 2020 15:37
-
-
Save Dornhoth/52ee78eba6a69a7dc60dbc1e04e63e29 to your computer and use it in GitHub Desktop.
Service Injection
This file contains hidden or 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'; | |
import { TestService } from 'src/app/services/test.service'; | |
@Component({ | |
selector: 'app-test', | |
templateUrl: './test.component.html', | |
styleUrls: ['./test.component.scss'], | |
}) | |
export class TestComponent implements OnInit { | |
text: string; | |
constructor( | |
private testService: TestService, // the DI makes sure you get an instance | |
) { } | |
ngOnInit() { | |
this.text = this.testService.getTest(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment