AngularJs : Inheritance in Controllers

Here is link of working example : http://jsfiddle.net/premaseem/jwenampL/2/

In order to take advantage of inheritance of scope in Nested controllers, one has to define Controllers one into another using ng-controller attribute. Sometimes you don’t want to define controllers like this but still want to use power of inheritance within controllers. May be you want to put common logic into BaseController and use it in all the child controllers.

In order to achieve this, we must use $injector object that AngularJS provides.

function BMWController($scope, $injector) {

$injector.invoke(CarController, this, {$scope: $scope});

$scope.name = 'BMW';

}

Wicket Markup Inheritance

Markup Inheritance lets a Component extend the markup of its super class. The subclass markup is inserted at one point in the super class markup.

Let’s see an example:

Parent.java:
public class Parent extends Component {}

Parent.html:

… parent content …
<wicket:child/>
… parent content …

Child.html

<wicket:extend>
… child content …
</wicket:extend>

Child.java:
public class Child extends Parent {}
Renders as:

… parent content …
… child content …
… parent content …

It is just like having a Panel defined in your Component class markup, and let subclasses add the Panel. But it doesn’t need an extra Component and is much easier to use. Markup Inheritance is also a convenient replacement for most Border components.

Markup Inheritance works with WebPages, so you can easily use the same header and footer on several pages.