Git Product home page Git Product logo

Comments (11)

hamidyfine avatar hamidyfine commented on July 3, 2024

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.

shuyu avatar shuyu commented on July 3, 2024

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.

hamidyfine avatar hamidyfine commented on July 3, 2024

Hi, Thanks for your reply. I will check it.
Thanks again.

from angular-material-fileinput.

hamidyfine avatar hamidyfine commented on July 3, 2024

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.

hamidyfine avatar hamidyfine commented on July 3, 2024

Have you checked about first problem?

from angular-material-fileinput.

shuyu avatar shuyu commented on July 3, 2024

Hi ~ can your provide some code about html ?

from angular-material-fileinput.

hamidyfine avatar hamidyfine commented on July 3, 2024

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.

hamidyfine avatar hamidyfine commented on July 3, 2024

@shuyu Hi ~ did you check the codes?

from angular-material-fileinput.

flavianh avatar flavianh commented on July 3, 2024

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.

dvelasquez avatar dvelasquez commented on July 3, 2024

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.

rainabba avatar rainabba commented on July 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.