Javascript AngularJS:通过JS在输入框中写入,不要在JSON中传输值

Javascript AngularJS:通过JS在输入框中写入,不要在JSON中传输值,javascript,angularjs,json,inputbox,Javascript,Angularjs,Json,Inputbox,背景:我有一个外部设备(条形码阅读器),当用户扫描某物时,它会将信息发送回平板电脑。我订阅了频道,我需要将值放在当前聚焦的单元格中,并将其写入其中 Bug:我可以捕获订阅并在输入框中直观地写入值,但它永远不会到达下面的JSON。 我还尝试了$scope.$apply(),但它没有改变任何东西(可能我用错了) $scope.randomClickOnStuff=函数(){ //在这里,随机发布有价值的内容,以便我们可以在特定字段中写入。 setTimeout(函数(){ 如果(!$scope.s

背景:我有一个外部设备(条形码阅读器),当用户扫描某物时,它会将信息发送回平板电脑。我订阅了频道,我需要将值放在当前聚焦的单元格中,并将其写入其中

Bug:我可以捕获订阅并在输入框中直观地写入值,但它永远不会到达下面的JSON。 我还尝试了
$scope.$apply()
,但它没有改变任何东西(可能我用错了)

$scope.randomClickOnStuff=函数(){
//在这里,随机发布有价值的内容,以便我们可以在特定字段中写入。
setTimeout(函数(){
如果(!$scope.stopMe){
publish(channelouse,Date.now());
$scope.randomClickOnStuff();
}否则{
//停止循环。
}
}, 1000);
};
var callbackCompleted=函数(resultValue){
//这里有重要代码
//要在此处输入框中写入的代码。
console.log(resultValue);
if(document.activeElement.localName==“输入”){
//备选案文1:

//-->可视化工作一种解决方案是通过将选定的行和单元格设置在其中一个单元格的焦点上来跟踪它们

$scope.focusedRow = false;
$scope.focusedCell = false;

$scope.setFocused = (row, cell) => {
  $scope.focusedRow = row;
  $scope.focusedCell = cell;
};

/* In callback... */
if ($scope.focusedRow !== false && $scope.focusedCell !== false) {
  $scope.$apply(
    () => $scope.complexObject[$scope.focusedRow]
      ["cellInTheRow"][$scope.focusedCell] = resultValue
  );
}

<input type="text" ng-model="row.cellInTheRow[key]"
  ng-focus="setFocused(rowKey, key)" ng-blur="setFocused(false, false)">
$scope.focusedRow=false;
$scope.focusedCell=false;
$scope.setFocused=(行、单元格)=>{
$scope.focusedRow=行;
$scope.focusedCell=单元格;
};
/*在回调中*/
if($scope.focusedRow!==false&$scope.focusedCell!==false){
$scope.$apply(
()=>$scope.complexObject[$scope.focusedRow]
[“cellinterrow”][$scope.focusedCell]=结果值
);
}

示例:

我尝试了许多其他选项,这是最有效的。没有选项卡灵活,因为我需要知道相关单元格的位置。因此每个部分都需要自己的自定义focusedCell。
$scope.focusedRow = false;
$scope.focusedCell = false;

$scope.setFocused = (row, cell) => {
  $scope.focusedRow = row;
  $scope.focusedCell = cell;
};

/* In callback... */
if ($scope.focusedRow !== false && $scope.focusedCell !== false) {
  $scope.$apply(
    () => $scope.complexObject[$scope.focusedRow]
      ["cellInTheRow"][$scope.focusedCell] = resultValue
  );
}

<input type="text" ng-model="row.cellInTheRow[key]"
  ng-focus="setFocused(rowKey, key)" ng-blur="setFocused(false, false)">