Duplication issue with dynamic form in tabs view <ion-slide> while coming from another tabs

i am creating a dynamic form like
var createForm="";
createForm += “

for(var i=0; i<2; i++){
createForm += “<input type=‘text’ ng-model=user,”+some_value+”>”
}else if(field_type==“password”){
createForm += “<input type=‘password’ ng-model=user,”+some_value+">"
createForm += “

var temp = $compile(createForm)($scope);

Note :- Here i have tried to use angular.element(document.getElementById(‘dynamic_form’)).html(temp);
but it is not working, div is not getting appear on the view.

Finally i got a way to solve the issue.

Here first i have added jQuery plugin to get support for

angular.element(document.body).html() function and then i did as mention below :-

var temp = $compile(createForm)($scope); angular.element(document.getElementById(‘dynamic_form’)).html(""); angular.element(document.getElementById(‘dynamic_form’)).append(temp);

this above lines solve my issue.

kindly correct me if my way is wrong.