Dynamically add directives in AngularJS

For a walkthrough see http://blog.fourtonfish.com/post/74055065673/dynamically-add-directives-in-angularjs-no-jquery

by Thunder Hemlock

HTML

<div ng-app="myApp" ng-controller="MainCtrl"></div>

CSS

section {
    padding: 2em;
}
button {
    padding:0.3em;
    margin: 0.3em;
}

JavaScript

var myApp = angular.module('myApp', []);

function MainCtrl($scope) {
    //var x = "fromWheel";
    //alert('x =  ' + x);

    $scope.thisSelectedTermObj = [{
        "name": "Form"
    }];

    console.log('name:  ' + $scope.thisSelectedTermObj[0].name);

    $scope.showAd = function (x) {
        alert('showAd FIRED!');
        alert('x =  ' + x);
        if (x == 'fromWheel') {
            if ($scope.thisSelectedTermObj[0].name === 'Imagery') {
                alert('Imagery fromWheel');
                if (AdMob) AdMob.showInterstitial();
            } else if ($scope.thisSelectedTermObj[0].name === 'Syntax') {
                alert('Syntax fromWheel');
                if (AdMob) AdMob.showInterstitial();
            } else if ($scope.thisSelectedTermObj[0].name === 'Conceit') {
                alert('Conceit fromWheel');
                window.adcolony.showFullScreenAd();
            } else if ($scope.thisSelectedTermObj[0].name === 'Meter') {
                alert('Meter fromWheel');
                window.adcolony.showFullScreenAd();
            } else if ($scope.thisSelectedTermObj[0].name === 'Symbolism') {
                alert('Symbolism fromWheel');
                window.adcolony.showFullScreenAd();
            } else {
                alert('no ad shown fromWheel');
            }
        } else if (x == 'fromExamples') {
            if ($scope.thisSelectedTermObj[0].name === 'Conventions') {
                alert('Conventions fromExamples');
                window.adcolony.showFullScreenAd();
            } else if ($scope.thisSelectedTermObj[0].name === 'Characterization') {
                alert('Characterization fromExamples');
                if (AdMob) AdMob.showInterstitial();
            } else {
                alert('No ad shown fromExamples');
            }
        } else if (x == 'fromIllustrated') {
            if ($scope.thisSelectedTermObj[0].name === 'Conventions') {
                alert('Conventions fromIllustrated');
              ...