angularjs - OnChange fires the first file input event -


i got custome directive:

angular.module('uvox-player').directive('customonchange', function() {     return {         restrict: 'a',         link: function (scope, element, attrs) {             var onchangehandler = scope.$eval(attrs.customonchange);             element.bind('change', onchangehandler);         }     }; }); 

and view 2 different inputs:

<div ng-show="platform == 'darwin'">     <input class="ng-hide" id="input-file-id" multiple type="file" custom-on-change="importplaylist"/>     <label for="input-file-id" class="md-button md-raised md-primary">import playlist</label> </div>   <div>     <input class="ng-hide" id="input-file-id" multiple type="file" custom-on-change="importcover"/>     <label for="input-file-id" class="md-button md-raised md-primary">new cover</label> </div> 

when click on second input event fired 1 declared in first input: importplaylist.

how can solve issue? thanks!

extra: methods onchange points to:

angular.module('uvox-player').controller('playlistbasecontroller', function($scope, api, $state, $q, $http, $mdtoast, ngdialog, $mddialog) {  $scope.importplaylist = function(event) {     var file = event.target.files[0];     api.postplaylistitunes('itunes[file]', file).then(function(data) {         $state.reload();     }, function(error) {     });  } 

and second input method:

angular.module('uvox-player').controller('playlistcovercontroller', function($scope, api, $state, $q, $http, $mdtoast, ngdialog, $stateparams) {  $scope.selectplaylist($stateparams.id); api.getplaylist($stateparams.id).then(function(data) {     $scope.cover = data.cover; }, function(error) { });   $scope.importcover = function(event) {     var file = event.target.files[0];     api.postplaylistcover($scope.selectedplaylist, 'cover[file]', file).then(function(data) {         $state.reload();     }, function(error) {     });  } 

});

if don't declare controller angularjs in main controller , in case could've find method importcover in playlistbasecontroller.

<div ng-controller="playlistbasecontroller" ng-show="platform == 'darwin'">     <input class="ng-hide" id="input-file-id" multiple type="file" custom-on-change="importplaylist"/>     <label for="input-file-id" class="md-button md-raised md-primary">import playlist</label> </div>   <div ng-controller="playlistcovercontroller">     <input class="ng-hide" id="input-file-id" multiple type="file" custom-on-change="importcover"/>     <label for="input-file-id" class="md-button md-raised md-primary">new cover</label> </div> 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -