Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么在angularjs中调用函数时,函数的值不能反映它们的值?(angularjs新增)_Javascript_Html_Angularjs - Fatal编程技术网

Javascript 为什么在angularjs中调用函数时,函数的值不能反映它们的值?(angularjs新增)

Javascript 为什么在angularjs中调用函数时,函数的值不能反映它们的值?(angularjs新增),javascript,html,angularjs,Javascript,Html,Angularjs,我需要在按下按钮调用下面HTML中定义的控制器函数时显示注释框部分的div…从表中提取索引值并验证ng if条件,如代码所示 <button class="btn btn-outlined" ng-click="vm.showCommentBox1($parent.$index, $index)">Save All</button> <div class="comment-box custom saveAll" ng-if="tableData.templat

我需要在按下按钮调用下面HTML中定义的控制器函数时显示注释框部分的div…从表中提取索引值并验证ng if条件,如代码所示

<button class="btn btn-outlined" ng-click="vm.showCommentBox1($parent.$index, $index)">Save All</button>
   <div class="comment-box custom saveAll" ng-if="tableData.template.selectedTowers[towerIndex].baselines[baselineIndex].toBeCommented">               
      <div class="panel panel-default">
          <div class="panel-heading">
              <button type="button" class="close" aria-label="Close" ng-click="baseline.toBeSaved = false" title="Close comment box"><span aria-hidden="true">×</span>
              </button>
              <h3 class="panel-title blue-30">Comment</h3>
          </div>
          <div class="panel-body">
              <form>
                  <div class="form-group">
                    <textarea class="form-control bg-white" ng-model="tableData.template.selectedTowers[$parent.$parent.$parent.$parent.$index].baselines[$index].comment"
                      placeholder="Add your description"></textarea>
                  </div>
                  <button ng-click="saveAllRows(tableData.dealName, tower.towerName, baseline, $parent.$parent.$parent.$parent.$index, $index, tower.towerGeo, tableData.template.selectedTowers[$parent.$parent.$parent.$parent.$index].baselines[$index].comment)"
                    class="btn btn-filled btn-xs pull-right">Submit</button>
                </form>
            </div>
        </div>
    </div> 
在上面的代码中,towerIndex和baselineIndex是未定义的,而当调用不同的函数时,它们有一些值

示例:下面的函数拥有两个参数的值

 vm.enableSaveButton = function (towerIndex, baselineIndex) {
  // console.log("Changed", baseline);
  $scope.tableData.template.selectedTowers[towerIndex].baselines[baselineIndex].toBeCommented = true;
}
在这种情况下,我被卡住了,我无法在我的HTML中传递ng if条件true,以便显示注释框

请帮帮忙


谢谢

因为它是表外的一个按钮,所以我无法从控制器中以($parent.$index,$index)的形式传递参数,因为只有表具有$index值…这是我的错,我一开始没有注意到。

vm的定义是什么?var vm=this@DevNull69代替vm作为变量,我也尝试使用$scope…参数仍然存在undefined@devnull69
 vm.enableSaveButton = function (towerIndex, baselineIndex) {
  // console.log("Changed", baseline);
  $scope.tableData.template.selectedTowers[towerIndex].baselines[baselineIndex].toBeCommented = true;
}