0

I have a object like this:

$scope.item ={
        fieldName:'First Name',
        fieldModel:'user.firstname',
        placeholder:'enter your name'
    }

and I want to compile this html form template like this:

<script type="text/ng-template" id="input.html">
    <div class="items form-group">
        <label class="col-sm-2 control-label">
            {{item.fieldName}}
        </label>
        <div class="col-sm-10">
            <input type="text" ng-model="{{item.fieldModel}}" placeholder="{{item.placeholder}}" class="form-control">
        </div>
    </div>
</script>

to html string that use pure html design:

<div class="items form-group">
     <label class="col-sm-2 control-label">
         First Name
     </label>
     <div class="col-sm-10">
         <input type="text" ng-model="user.firstname" placeholder="enter your name" class="form-control">
     </div>
</div>
0

1 Answer 1

1

You can include your template with:

<div id="tpl-content" ng-include src="input.html"></div>

but your template should be:

<script type="text/ng-template" id="input.html">
<div class="items form-group">
    <label class="col-sm-2 control-label">
        {{item.fieldName}}
    </label>
    <div class="col-sm-10">
        <input type="text" ng-model="item.fieldModel" placeholder="{{item.placeholder}}" class="form-control">
    </div>
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

You didn't understand my means. I wan to create html generator with angularjs. I want to generate html that copyable like this bootsnipp.com/forms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.