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. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題2. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. 我何時應該在Java中使用JFrame.add(component)和JFrame.getContentPane()。add(component)4. docker - 如何修改運行中容器的配置5. docker鏡像push報錯6. html5和Flash對抗是什么情況?7. javascript - 請指條明路,angular的$event,在select中卻是undefined?8. 利用IPMI遠程安裝centos報錯!9. javascript - 在 model里定義的 引用表模型時,model為undefined。10. phpstudy8.1沒集成mysql-front

網公網安備