I am a beginner with AngularJS and I'm currently working on writing a directive that wraps an input box inside a form tag, followed by a 'div' element which includes validation. Unfortunately, the validation is not functioning as expected. You can find my Plunker link here: PLUNKER
Below is the code snippet where I wrap the input tag:
var getHtml = function(){
return '<div data-ng-show="myform.myfield.$error.required && myform.myfield.$dirty">field is required</div>';
}
element.attr('name', 'myfield');
element.wrap('<form name="myform"></form>');
element.after(getHtml());