Я пытаюсь сделать директиву с разными шаблонами на основе значения области.
Это то, что я сделал до сих пор, и я не знаю, почему не работает http://jsbin.com/mibeyotu/1/edit
Элемент HTML:
<data-type content-attr="test1"></data-type>
Директива
var app = angular.module('myApp', []);
app.directive('dataType', function ($compile) {
    var testTemplate1 = '<h1>Test1</h1>';
    var testTemplate2 = '<h1>Test2</h1>';
    var testTemplate3 = '<h1>Test3</h1>';
    var getTemplate = function(contentType){
        var template = '';
        switch(contentType){
            case 'test1':
                template = testTemplate1;
                break;
            case 'test2':
                template = testTemplate2;
                break;
            case 'test3':
                template = testTemplate3;
                break;
        }
        return template;
    }; 
    var linker = function(scope, element, attrs){
        element.html(getTemplate(scope.content)).show();
        $compile(element.contents())(scope);
    };
    return {
        restrict: "E",
        replace: true,
        link: linker,
        scope: {
            content:'='
        }
    };
});