0

I am generating a form dynamically in my application. The fields of the forms are the column names in the database table.The user of this application will just pass the name of the table and the skeleton for CRUD application will be prepared dynamically.

In the view part I want to achieve something like this

  <div class="form-group" ng-repeat="(key,col) in cols">
    <label for="{{::col}}">{{::col | uppercase | replaceUnderscore}}</label>
    <input class="form-control" type="text"  ng-model="{{::col}}"  required />
</div>

In the ng-model I just need the string value that is, if the column name is Username then model value should be something like ng-model="username" and the value should not be displayed in the form field. So I want to achieve kind of one way data binding.

2
  • When you have ng-model="username" is the input value the actual username? i.e. johndoe? Commented Jun 25, 2015 at 10:35
  • the col array has all the column names i just need to write ng-model="whatever column name". Commented Jun 25, 2015 at 10:42

1 Answer 1

1

Simply use a JS object, for example $scope.data = {}, and then ng-model="data[col]".

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

Comments

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.