Hi all,
I have to create a file upload component (custom directive) which has to look something like this:
Problem is that my upload-components which have following template are invalid so I cannot submit the form (+ I also need to define an ng-model).
<div class="form-group">
<div ng-repeat="fn in fileNames">
<div class="form-group" ng-attr-id="{{fn + 'Row'}}">
<div class="row">
<div class="col-sm-6">
<input type="file"
class="form-control"
ng-model="$parent.fileModels[fn]"
cam-variable-name="{{fn}}"
cam-variable-type="File"
cam-max-filesize="10000000"/>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-default" ng-click="removeFile(fn)">
<span class="glyphicon glyphicon-minus-sign"></span>
</button>
</div>
</div>
</div>
</div>
</div>
Failed validation (camVariableType error + required error)
<input type="file" class="form-control ng-dirty ng-invalid ng-invalid-cam-variable-type" ng-model="$parent.fileModels[fn]" cam-variable-name="DYN_FILE_1460965019162" cam-variable-type="File" cam-max-filesize="10000000">
I think all these exceptions is related to the fact that some of the behavior of the directives are not defined in the controllers but in custom external code;
// next perform auto-scope binding for all fields which do not have custom bindings
function autoBind(key, el) {
var element = $(el);
if(!element.attr('ng-model')) {
var camVarName = element.attr(constants.DIRECTIVE_CAM_VARIABLE_NAME);
if(!!camVarName) {
element.attr('ng-model', camVarName);
}
}
}
I could be mistaken so if there is a way to fix this I would be more than happy to hear it.
Kr,
Nico