JSFiddle - React, Tailwind, and code Playground

by Aaron Zhang

HTML

<div ng-app="myApp" ng-controller="myCtrl">{{ hi }}</div>

JavaScript

(function () {
    'use strict';
    Object.prototype.inherit = function (parent) {
        this.prototype = Object.create(parent.prototype);
        this.prototype.$super = function(funcName,args){
            return parent.prototype[funcName].apply(this,args);
        };
    };
})();
(function () {
    'use strict';
    var app = angular.module('myApp', []);
    app.factory('Parent', function () {
        function Parent(name) {
            console.log('Init Parent');
            this.name = name;
        }
        Parent.prototype.sayHi = function () {
            return 'Hi ' + this.name + ' from Parent';
        };
        return Parent;
    });

    app.factory('Child', ['Parent', function (Parent) {
        function Child(name) {
            Parent.call(this, name);
            console.log('Init Child');
        }
        Child.inherit(Parent);
        Child.prototype.sayHi = function () {
            var parentHi = this.$super('sayHi');
            return parentHi + ' Hi ' + this.name + ' from Child';
        };
        return Child;
    }]);
    app.controller('myCtrl', function (Parent, Child, $scope) {
        var aaron = new Child('Aaron');
        $scope.hi = aaron.sayHi();
    });
})();