angular.js - angular 視圖未更新
問題描述
如圖 選擇文件上傳后,Input內會有文件路徑對應顯示,過程中不點擊上傳按鈕,這時點擊取消窗口后,再次打開,文件路徑依舊存在。
$(’.part1_top_right’).click(function(){ $(’.part1’).hide(); $(’.part2’).hide(); $(’.part3’).hide(); $(’.part4’).hide(); $(’.part5’).hide();$scope.filePath='';$scope.cleanSelectFiles();});$scope.cleanSelectFiles = function(){ if(uploader.queue.length > 0){uploader.clearQueue();}}
點擊取消時,Input內以為空, console.log其值也為空。
是否使用$scope.$apply? 并且在哪里使用?
問題解答
回答1:$(’.part1_top_right’).click(function(){ $(’.part1’).hide(); $(’.part2’).hide(); $(’.part3’).hide(); $(’.part4’).hide(); $(’.part5’).hide();$scope.filePath=''; $scope.$apply(); $scope.cleanSelectFiles();});$scope.cleanSelectFiles = function(){ if(uploader.queue.length > 0){uploader.clearQueue();}}回答2:
$(’.part1_top_right’).click(function(){ $(’.part1’).hide(); $(’.part2’).hide(); $(’.part3’).hide(); $(’.part4’).hide(); $(’.part5’).hide();$scope.filePath='';//這就是你的input?如果是,那$apply在這就行 $scope.$apply();$scope.cleanSelectFiles();});$scope.cleanSelectFiles = function(){ if(uploader.queue.length > 0){uploader.clearQueue(); }}
相關文章:
1. html5 - 如何實現帶陰影的不規(guī)則容器?2. html5 - 只用CSS如何實現input框的寬度隨框里輸入的內容長短自動適應?3. javascript - 三目運算符的一些問題4. python - uwsgi+django的搭建問題5. css - 移動端字體設置問題6. javascript - ueditor引入報錯問題7. c++ - win7在不刪除管理員密碼的前提下(密碼不為空),如何設置開機不需要密碼?8. html5 - H5 video 問題9. javascript - 移動端上不能實現拖拽布局嗎?10. javascript - 循環(huán)嵌套多個promise應該如何實現?
