Как создать директиву с динамическим шаблоном в AngularJS?

Как я могу создать директиву с динамическим шаблоном?

'use strict';

app.directive('ngFormField', function($compile) {
return {
    transclude: true,
    scope: {
        label: '@'
    },
    template: '<label for="user_email">{{label}}</label>',
    // append
    replace: true,
    // attribute restriction
    restrict: 'E',
    // linking method
    link: function($scope, element, attrs) {
        switch (attrs['type']) {
            case "text":
                // append input field to "template"
            case "select":
                // append select dropdown to "template"
        }
    }
  }
});
<ng-form-field label="First Name" type="text"></ng-form-field>

Это то, что у меня есть сейчас, и оно правильно отображает метку. Однако я не уверен, как добавить дополнительный HTML в шаблон. Или объединяя 2 шаблона в 1.

Ответы на вопрос(7)

Ваш ответ на вопрос