我得到这个custome指令:的OnChange触发的第一个文件输入事件
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);
}
};
});
和2个不同的输入一个观点:
<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>
当我点击第二个输入触发的事件是一个在第一个输入中声明:importPlaylist。
我该如何解决这个问题? 谢谢!
额外:的方法,其中的onChange点:
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) {
});
}
和第二输入方法:
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) {
});
}
});
为了调试的目的,您是否可以删除第一个输入并查看该行为是否持续? – Vega
是的,已经尝试过,它工作正常。 –
你是否已经修好了发行? – Vega