JSFiddle - React, Tailwind, and code Playground

by Jeremy Likness

HTML

<div ng-app="myApp" ng-controller="myController">{{html}}</div>

JavaScript

(function () {
    var app;
    app = angular.module("myApp", []);

    app.config(['$provide', '$httpProvider', function (p, hp) {
        p.factory('myHttpInterceptor', function ($q) {
            return {
                request: function (config) {
                    console.log("request");
                    console.log(config);
                    return config || $q.when(config);
                },

                requestError: function (rejection) {
                    console.log(rejection);
                    return $q.reject(rejection);
                },

                response: function (response) {
                    console.log("response");
                    response.data = "<p>" + response.data.replace(/<(.|\n)+?>/g, "").replace(/\s+/g, ' ') + "</p>";
                    console.log(response);
                    return response || $q.when(response);
                },

                responseError: function (rejection) {
                    console.log(rejection);
                    return $q.reject(rejection);
                }
            };
        });
        hp.interceptors.push('myHttpInterceptor');
    }]);

    app.controller("myController", function ($scope, $rootElement, $compile, $http) {
        $scope.html = "loading...";
        $http({url:'/', method: 'GET'}).then(function(response){
            $rootElement.append($compile(response.data)($scope.$new()));
        });
    });
})();