Code Monkey home page Code Monkey logo

ng-ab's Introduction

ngAB

AngularJS AB Testing and Multivariate Testing Module

ngAB is an AngularJS module that facilitates AB testing, split testing, and multivariate testing. ngAB intercepts AngularJS templates and edits them according to your specifications using regexp. This allows you to replace HTML, add different styling, and even augment your scripts.

Usage

This simple example watches for the /templates/angular/home.html file in $http requests. Upon finding it, ngAB replaces all h1 tags with h4 tags.

// Declare ngAB as a dependency
var myModule = angular.module('myModule', ['ngAB']);

// Assign the AB testing spec
module('ngAB').value('spec', {
    '/templates/angular/home.html': {
        'steps': {
            perm: 'vertical',
            changes: [{
                find: '<h1>',
                replace: '<h4>',
                flags: 'g'
            }, {
                find: '</h1>',
                replace: '</h4>',
                flags: 'g'
            }]
        }
    }
});

// That's it!

Changing CSS

If the find value is left empty for any change element, the replace value is automatically appended to the template. This makes it easy to change styling after the fact:

module('ngAB').value('spec', {
    '/templates/angular/home.html': {
        'body-text-color': {
            perm: 'red',
            changes: [{
                find: '',
                replace: '<style>body {color: red;}</style>',
                flags: ''
            }]
        }
    }
}

Changing JS

Just like changing CSS, but trickier in implementation. Good luck!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.