Customizing the template within a Directive

前端 未结 4 1541
醉话见心
醉话见心 2020-11-28 00:25

I have a form that is using markup from Bootstrap, like the following:

Legend tex
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 01:17

    angular.module('formComponents', [])
      .directive('formInput', function() {
        return {
            restrict: 'E',
            compile: function(element, attrs) {
                var type = attrs.type || 'text';
                var required = attrs.hasOwnProperty('required') ? "required='required'" : "";
                var htmlText = '
    ' + '' + '
    ' + '' + '
    ' + '
    '; element.replaceWith(htmlText); } }; })

提交回复
热议问题