I have the HTML like below
<div class="col-md-12">
<div class="col-md-4" ng-class="{ 'has-error' : submitted && form.field_format.$invalid }">
<label for="field_format">Type</label>
<select class="form-control" name="field_format" id="field_format" data-ng-model="form.field_format" required>
<option value="text">Text</option>
<option value="image">Image</option>
</select>
<div ng-show="submitted && form.field_format.$invalid" class="help-block">
<p ng-show="form.field_format.$error.required">Field format is required</p>
</div>
</div>
<div class="col-md-7" ng-class="{ 'has-error' : submitted && form.field_value.$invalid }">
<label for="field_value">Value</label>
<input type="text" class="form-control" name="field_value" id="field_value" data-ng-model="form.field_value" placeholder="Enter Value" required/>
<div ng-show="submitted && form.field_value.$invalid" class="help-block">
<p ng-show="form.field_value.$error.required">Field value is required</p>
</div>
</div>
</div>
I want to implement the following functionalities
- On Change the
field_format
from theselect box
, change thefield_value
input type totext/file
- Upload
file/text
I have read How to upload file using angular and the NodeJS uploading file is working for me, but I am not sure how can I achive the uploading file / text in the dynamic form like this?
The select box is rendering with the <option value="? undefined:undefined ?"></option>
How can I make it to select the text default?