Dependency Injection in Angular

Dependency Injection in Angular

I have 2 file services (data-parent.service.ts, data-child.service.ts). Both have a() function names. data-child.service.ts extends data-child.service.ts.

I have 2 file services (data-parent.service.ts, data-child.service.ts). Both have a() function names. data-child.service.ts extends data-child.service.ts.

app-root.component.ts

@Component({
    selector: 'app-root',
    templateUrl: './app-root.component.html',
    styleUrls: ['./app-root.component.scss']
})
export class AppRoot extends DataParent{
    clicka = () => {
        console.log('click a');
        this.a();
   }
}

data-parent.service.ts

@Injectable()
export class DataParent{
    a(): void {
        console.log('a DataParent');
    }
}

data-child.service.ts

@Injectable()
export class DataChild extends DataParent {
   a = () => {
      console.log('a DataChild');
      super.a();
   }
}

How to do this when the app-root component calls function name a () of data-child.service.ts, the function a () of data-child.service.ts executes.

Result: "click a" "a DataChild" "a DataParent"

angular angular.js

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Basics of Angular: Part-1

What is Angular? What it does? How we implement it in a project? So, here are some basics of angular to let you learn more about angular. Angular is a Typesc

What are the best alternatives for angular js?

<img src="https://moriohcdn.b-cdn.net/193902114c.png">There are numerous frameworks and libraries used across the globe. If not angular, there are platforms like React, Vue, Aurelia and so on for app development.

Angular 8 Node & Express JS File Upload

In this Angular 8 and Node.js tutorial, we are going to look at how to upload files on the Node server. To create Angular image upload component, we will be using Angular 8 front-end framework along with ng2-file-upload NPM package; It’s an easy to use Angular directives for uploading the files.

How to Implement Server Side Pagination with Angular 8 and Node.js

A simple example of how to implement server-side pagination in Angular 8 with a Node.js backend API.