-
-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Description
Hi !
I've been using dyn-form for a while and it's great, it helps me a lot ! So thanks !
One thing I didn't use so far was the <input type="file"/>, and I had trouble using it. Your readme file misses maybe some usage example (or I missed it)
- Unclear if you have to use the
"callback":"readFile()"(ng-change) or"attributes": {"on-change":"readFile()"}(it's the latter) - Don't forget to had
fileReaderinjected in your controller - In the example linked in your readme, the function is
fileReader.readAsDataUrlin your plugin it'sfileReader.readAsDataURL(URL full caps ^^)
Example for one image file :
$scope.formData = {};
$scope.imageSrc = ""
$scope.formTemplate = [
{
"type": "file",
"model": "image",
"label": "Image",
"attributes": {"on-change":"readFile()"}
}
];
$scope.readFile = function () {
fileReader.readAsDataURL($scope.formData["image"][0], $scope)
.then(function(result) {
//display the image on file change
$scope.imageSrc = result;
});
};
// ... do some stuff<dynamic-form template="formTemplate"
ng-model="formData"
ng-submit="processForm()">
</dynamic-form>
<!-- image preview -->
<img ng-src="{{imageSrc}}"/>Not much but if it can help people (like me) understand better how it works without looking to the source file, I leave it here !
Metadata
Metadata
Assignees
Labels
No labels