Comments (11)
Another issue with this code is that, I want to save file info ($scope.files) to another $scope to use it later. But it doesn't work.
What Should i do?
from angular-material-fileinput.
Hi ! the first problem maybe is related to angular version , i will check it as soon as i can.
and the second problem you should use copy or reference to per file.
var filesTmp = angular.copy($scope.files);
var fileTmp = $scope.files[0];
from angular-material-fileinput.
Hi, Thanks for your reply. I will check it.
Thanks again.
from angular-material-fileinput.
It didn't work, too.
here is my code:
$scope.filesTmp = {};
// Upload
$scope.$watch('files.length', function(newVal, oldVal) {
console.log($scope.files);
$scope.myCroppedImage='';
$scope.fileURLAddress='';
$scope.isNull = true;
$scope.avatarEditing = false;
$scope.avatarCropped = false;
// $scope.filenameVar = $scope.files[0].lfFileName;
$scope.filesTmp = angular.copy($scope.files);
if($scope.files.length != 0){
$scope.fileURLAddress = $scope.files[0].lfDataUrl;
$scope.isNull = false;
$scope.avatarEditing = true;
} else {
$scope.fileURLAddress = null;
}
});
console.log("Start Outside");
console.log($scope.filesTmp);
I need upload file info save in $scope.filesTmp
and I use it outside of $scope.$watch
.
from angular-material-fileinput.
Have you checked about first problem?
from angular-material-fileinput.
Hi ~ can your provide some code about html ?
from angular-material-fileinput.
Hi.
<md-input-container class="[ md-block md-input--grey md-has-icon--fix ]">
<lf-ng-md-file-input
class="[ mv0 ]"
lf-files="files"
accept="image/*"
progress>
</lf-ng-md-file-input>
</md-input-container>
from angular-material-fileinput.
@shuyu Hi ~ did you check the codes?
from angular-material-fileinput.
Hey @hamidyfine, found a possible solution for you since I had exactly the same problem.
If you have your controller defined thusly:
var myModule = angular.module('someModule', []);
Then you'd like to change it to
var myModule = angular.module('someModule', ['lfNgMdFileInput']);
I am using states in my app so I have several sub-modules like this. In short, the library seems to have scope issues. In length, I have no idea why this solves the problem, but someone better than me at scope management could help.
from angular-material-fileinput.
I have a similar issue. My problem was use ng-if.
<div flex="100" layout="row" layout-align="start center" ng-if="data.showFileList">
<lf-ng-md-file-input lf-files='files' multiple lf-browse-label="Buscar Archivo"
lf-placeholder="Seleccionar Archivos">
</lf-ng-md-file-input>
</div>
When the view is created, ng-if dont render that block of the DOM, so, $scope.files was never available and always 'undefined'.
Changing for a ng-show make it work
<div flex="100" layout="row" layout-align="start center" ng-show="data.showFileList">
<lf-ng-md-file-input lf-files='files' multiple lf-browse-label="Buscar Archivo"
lf-placeholder="Seleccionar Archivos">
</lf-ng-md-file-input>
</div>
from angular-material-fileinput.
You need to initialize the object as an array. You're trying to watch for .length on an object that isn't an array when you setup the watch (because it's still null or undefined, not having been used).
Since you're binding to $scope.files declaratively, just set $scope.files = []
in your controller so it's get's initialized and do that before trying to setup the watch.
from angular-material-fileinput.
Related Issues (20)
- like ng-change on fileinput HOT 4
- Getting warning when I add angular-material-fileinput in my code
- [FEATURE] Add return check to lfOnFileRemove event HOT 1
- Any update in angular 2
- Error on Load: Trying to load lfNgMdFileinput.html? HOT 1
- Unhandled exception if files is not an array
- Zip file previews binary content
- lf-required with condition
- Convert files to base64 format
- Show preview file without binary data
- Cannot read property 'name' of undefined HOT 2
- onSubmitClick with parameters
- "Adobe PDF Document - Access denied." Pop-up when previewing a PDF on IE11
- "Choose Files" still showing ontop of BROWSE button
- Sketch files freeze the browser
- Add lf-required Conditionally based on value HOT 1
- error when using it with angular 4 HOT 1
- How can use multiple image input on same page ? HOT 1
- Add support for npm HOT 1
- Selecting directories
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-material-fileinput.