AngularJS : Can a directive template contain a form element? -


is possible use form element inside angular directive template? e.g. might want generate form save on repetitive coding - html shows data, directive auto-generates editing. find useful edit pages repeat lot:

<div data-editable="true">   <span>{{item.name}}</span>         </div> 

and directive:

.directive('editable',function(){    return {        restrict: 'ae',        require: '^form',        transclude:true,        scope: {}, // set after...        template:'<div><form name="someform"><span>form</span></form></div>',        link: function(scope,elm,attrs,controller) {            //nothing here quite yet...        }    }; }); 

yet when run it, output not transclude, , form element stripped out:

<div data-editable="true" class="ng-isolate-scope"><div><span>form</span><ng-transclude></ng-transclude></div></div> 
  • the <span>{{item.name}}</span> not transcluded in
  • the <form> element stripped out

what doing wrong?

there 2 problems here:

  1. there <form> inside <form>, stripped out either browser or angular (i don't care which).
  2. angular pre-1.3.0 seems support ng-transclude in template only attribute. 1.3.0 onwards supports element well.

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -