JSFiddle - React, Tailwind, and code Playground

by rur_d

HTML

<script src="http://code.angularjs.org/angular-1.0.0rc8.js"></script>
<div ng-app="test">
    <div ng-controller="MainCtrl">
        <p>Value = {{value}}</p>
        <input type="text" ng-model="message">
        <input type="button" name="logit" value="Log It" id="logit" ng-click="logit(message)">
    </div>
</div>

JavaScript

/**
     * test Module
     *
     * Description
     */
    angular.module('test', [], function ($provide) {
        $provide.factory('augmentController', [ '$injector', '$parse', '$window', function ($injector, $parse, $window) {
            return function augmentController (Class, controller, locals) {
                var scope = locals.$scope;

                if (angular.isString(Class)) {
                  var getter = $parse(Class);
                  Class = getter(scope) || getter($window);
                }

                var classPrototype = Class.prototype;
                for(var key in classPrototype) {
                    controller[key] = angular.bind(controller, classPrototype[key]);
                }

                return $injector.invoke(Class, controller, locals);
            }
        }])
    })
    
    function MainCtrl ($scope, augmentController) {
        var locals = {
          $scope: $scope
        };
        extCtrl = augmentController("SubCtrl", this, locals);
        this.log("got log!");
        $scope.logit = this.logit;   
    }
    
    function SubCtrl ($scope, $log) {
        $scope.value = "This is a sub value"
        this.log = $log.log;
    }
    
    SubCtrl.prototype.logit = function  (msg) {
        this.log("new message: " + msg);
    }