我得到了这个客户指令:
<session-config>
<session-timeout>
15
</session-timeout>
</session-config
有两个不同输入的视图:
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);
}
};
});
当我点击第二个输入时,触发的事件是在第一个输入中声明的事件:importPlaylist。
我该如何解决这个问题? 谢谢!
额外:onChange指向的方法:
<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>
第二种输入法:
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) {
});
}
});
答案 0 :(得分:0)
如果您没有声明控制器,AngularJs将在主控制器中查找,在您的情况下,它可以在PlaylistBaseController中找到方法importCover。
<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>
答案 1 :(得分:0)
尽管在路由上定义了正确的控制器,但失败仍然存在,直到我意识到由于复制/粘贴导致两个输入具有相同的id而导致的不稳定行为.... 改变了id,问题解决了......