Inheritance in angularJS

So you don’t know about javascript prototyping right ?

Ohhh you know this then its ok, Please read fast

Ohhh you really do not know about javascript prototyping, then you need to go slow, yes very slow !

In javascript you must have declared variables and functions. Have you ever declared objects in javascript. Even in javascript we can write object oriented programming, yes you read it right, OOPs is there in javascript. That ultimately telling you the most powerful feature of object oriented programming so called “Inheritance” is there in Javascript.

Inheritance is a feature which will allow you to copy or inherited the properties and methods of parent class.

Lets comeback to super sonic Framework, i mean the AngularJS

Before you go ahead, to continue with this article you must be familiar with controller in AngularJS. So AngularJS will allow you to copy properties and methods from 1 controller to another controller.

Usually how we declare a simple controller in AngularJS

<div ng-controller=”parent”>

{{parentVariableName}}

</div>

 

Usually how we declare a simple inherited controller in AngularJS

<div ng-controller=”parent”>

{{parentVariableName}}

<div ng-controller=”child”>{{childVariable}}</div>

</div>

 

Then what is the advantage of this :)

Child controller can manipulate the properties of parent variable. So “parentVariableName” scope can be manipulated in “child’ controller.

 

Keep Coding :)