亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JavaScript/ AngularJS:只有當我單擊兩次按鈕時才會顯示錯誤消息

JavaScript/ AngularJS:只有當我單擊兩次按鈕時才會顯示錯誤消息

收到一只叮咚 2022-08-27 15:25:08
我有一個angularJS視圖,允許用戶上傳Excel數據并將其導入SQL服務器表。我添加了數據的客戶端驗證,但僅當我再次單擊“上載/導入”按鈕時,才會顯示錯誤消息。我不確定代碼中的哪個部分導致了此問題。是否可以尋求幫助以嘗試解決此問題?我想我可能需要移動變量賦值的位置,但在哪里?$scope.Message我包括Javascript / angularjs代碼和html視圖。AngularJS//Parse Excel Data   $scope.ParseExcelDataAndSave = function () {    var file = $scope.SelectedFileForUpload;    if (file) {        var reader = new FileReader();        reader.onload = function (e) {            var filename = file.name;            // pre-process data            var binary = "";            var bytes = new Uint8Array(e.target.result);            var length = bytes.byteLength;            for (var i = 0; i < length; i++) {                binary += String.fromCharCode(bytes[i]);            }            // call 'xlsx' to read the file            var data = e.target.result;            var workbook = XLSX.read(binary, { type: 'binary', cellDates: true, cellStyles: true });            var sheetName = workbook.SheetNames[0];            var excelData = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);            exceljsonObj = excelData;            var errors = [];            var rowCounter = 1;            for (var j = 0; j < exceljsonObj.length; j++) {                var xdata = exceljsonObj[j];                if (xdata['Meeting ID'] === undefined || xdata['MeetingID'] === undefined) {                    errors.push('Row: ' + rowCounter + ' is missing the Meeting ID value.' +                                ' Please, verify that the data you are trying to upload meets the required criteria, ' +                                'and then try to upload your file again.');                }};
查看完整描述

1 回答

?
胡說叔叔

TA貢獻1804條經驗 獲得超8個贊

$scope摘要問題。分配$scope后調用 $scope.apply()。消息


if (errors.length > 0) {

            $scope.Message = 'Please, verify that the file you are trying to upload is correctly formatted, \n ' +

                                'and that the data it contains, meets the expected criteria, then click the upload button again. \n Thank you!'


    $scope.$apply();

 }


查看完整回答
反對 回復 2022-08-27
  • 1 回答
  • 0 關注
  • 124 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號