angular-class-extender

A lightweight angular module that adds support for multiple class inheritance and method abstraction.
Homepage:
1 person uses it
Author: 638fa0a11d0cb897a6dab71bfdcacf49?d=https%3a%2f%2fidenticons.github.com%2f0b618583b72dfe59b3ee149fd0405b93 roypeled

angular-class-extender

A lightweight angular module that adds support for class inheritance and method abstraction.

Here is the DEMO

This module will help you minimize code duplication by classic methods of inheritance.

Usage

To use this module you must add the JS file to your HTML and add ngExtender as a dependency to your app: ```html <!DOCTYPE html> ...

Basic Inheritance

Now calling foo() or help() from ChildClass would actually call foo() from ParentClass and do 'A' or help() from HelperClass.

Overriding Methods and Calling Super Methods

Calling foo() from ChildClass would perform the overidden method, and the ParentClass method by calling $super.

Implementing Abtract Methods

Using the $abstract syntax you are making sure that whichever class extended ParentClass it has to implement bar() method. Not doing so would result in an error:

Abstract method bar must be overriden in ChildClass!

Binded Event

This handler is called after all the classes in your inheritance tree have been linked, so you can be sure you can access all of the inherited or implemented properies. ```js function ParentClass($scope){ window.alert($scope.bar); // undefined

$scope.$binded(function(){ window.alert($scope.bar); // hello world! });

$scope.$abstract("bar"); }

function ChildClass($extend, $scope){ $extend($scope).with(ParentClass);

$scope.bar = "hello world!" } ```

Unit Testing

Angular Class Extender now fully supports unit testing by using the injected class $extendedController instead of $controller

comments powered by Disqus
This page was last updated almost 4 years ago.