Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After selecting files, they does not bind to scope #63

Open
Mady007 opened this issue Jan 21, 2017 · 2 comments
Open

After selecting files, they does not bind to scope #63

Mady007 opened this issue Jan 21, 2017 · 2 comments

Comments

@Mady007
Copy link

Mady007 commented Jan 21, 2017

I'm able to select files but when I click submit to post them to the server the $scope.files is undefined. The $watch is not triggered when I select files.

Html:
<lf-ng-md-file-input lf-files="files" multiple></lf-ng-md-file-input>

Js:

Module:
angular.module('documentModule', [ 'ngRoute', 'ngMaterial', 'ngAnimate' ,'lfNgMdFileInput' ]);

Controller:

angular.module('documentModule').controller('documentViewModel', documentViewModel); documentViewModel.$inject = ['$scope','$http'];

  function documentViewModel($scope, $http) {
     //$scope.files =[];
      $scope.$watch('files.length', function (newVal, oldVal) {
        console.log($scope.files);
      });
 }

I have read that lf-files="files" acts similar to ng-model ="files" but it does not bind to $scope.

@ipuiu
Copy link

ipuiu commented Apr 5, 2017

Same issue here with angular 1.6.3 and angular-material 1.1.3. $scope.files never gets updated, even if I initialize it with an array.

@zuhrasofyan
Copy link

For those who experience similar problem, check if in your parent div that encapsulated the fileinput use ng-if(or if you use ng-if in the fileinput itself). Apparently, it blocks the $scope.files and always return undefined. Try to remove ng-if and see it works as usual. At least that is what happen in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants