0

我有一个需要向子控制器广播的刷新功能。我在父控制器中做了这样的事情:

      // Refresh/Cancel
  $scope.OnGridBODRefresh() = {
        function () {
         $scope.$broadcast('refresh',$scope.dtBODStartValue,$scope.dtBODStopValue);                                  
        }          
        } 

在子控制器中:

      // Refresh/Cancel
  $scope.OnGridBODRefresh = function () {        
    // Filter setzen
    kendoHelper.SetDataSourceFilters($scope.gridBODProductionRequests.dataSource, "BODTime", "gte", $scope.dtBODStartValue);    // gte Kendo Operator
    kendoHelper.SetDataSourceFilters($scope.gridBODProductionRequests.dataSource, "BODTime", "lte", $scope.dtBODStopValue);       // lte Kendo Operator
  }
   
  $scope.dtChildStopValue = new Date();
  $scope.dtChildStartValue = new Date($scope.dtChildStopValue - 7 * TIMEINTERVAL_PER_DAY_MS);
     
      $scope.$on('refresh', function (event, dtBODStartValue, dtBODStopValue) {
           $scope.dtChildStartValue = dtBODStartValue;
           $scope.dtChildStopValue = dtBODStopValue;
         }
         )         

它应该在“取消”按钮上激活。我有一个错误:

“$scope.OnGridBODRefresh 不是函数”

在控制台中。有人知道吗?

这是我的控制器和视图之间的链接:

<table border="0" class="navigationBar">
    <tr>
        <td class="navigationBar-left">
            ({{refreshcount}})
            <kendo-button class="k-primary button button-save" ng-click="OnGridBODSave()">Save</kendo-button>
            <kendo-button class="k-primary button button-cancel" ng-click="OnGridBODRefresh()">Cancel</kendo-button>
        </td>
        <td class="navigationBar-right">
            @PLanguageTexts.TXT_AUTO_REFRESH:  <input type="checkbox" name="checkBoxAutomaticRefresh" ng-model="checkBoxAutomaticRefreshValue" ng-true-value="1" ng-false-value="0" ng-change="OnCheckBoxAutomaticRefreshChange(e)">
            | 
            @PLanguageTexts.TXT_BOD_TIME
          <input kendo-date-time-picker="dateTimePickerBODStart" k-ng-model="dtBODStartValue" k-options="dateTimePickerBODStart"/>
          <input kendo-date-time-picker="dateTimePickerBODStop" k-ng-model="dtBODStopValue" k-options="dateTimePickerBODStop"/>
        </td>
    </tr>
</table> 


 <div ng-controller="BODProductionRequestsCtrl">  
           <div kendo-grid="gridBODProductionRequests" k-options="gridBODProductionRequests(dataItem)">
              <div k-detail-template>
                <kendo-tabstrip>
                  <ul>
                      <li class="k-state-active">@PLanguageTexts.TXT_COMMENT</li>
                  </ul>
                  <div>
                    <textarea id="BODProductionRequestsComment" class="textarea-gridComment" ng-model="dataItem.Comment" ng-change="OnCommentChange(dataItem, gridBODProductionRequests)"></textarea>
                  </div>
                </kendo-tabstrip>
              </div>
        </div>
        {{dtChildStartValue}}
  </div>  
4

1 回答 1

1
  // Refresh/Cancel
$scope.OnGridBODRefresh = function () {
        $scope.$broadcast('refresh',$scope.dtBODStartValue,$scope.dtBODStopValue);                                  
    }  

我不明白你为什么将你的函数包装到一个对象中。如果您删除函数周围的括号,它会像魅力一样工作。

另一个问题是您的 ng-click 不在链接到控制器的 div 内。试着那样做。如果它不起作用,剑道也可能存在问题,我将无法提供帮助。

 <div ng-controller="BODProductionRequestsCtrl">  
    <table border="0" class="navigationBar">
            <tr>
                <td class="navigationBar-left">
                    ({{refreshcount}})
                    <kendo-button class="k-primary button button-save" ng-click="OnGridBODSave()">Save</kendo-button>
                    <kendo-button class="k-primary button button-cancel" ng-click="OnGridBODRefresh()">Cancel</kendo-button>
                </td>
                <td class="navigationBar-right">
                    @PLanguageTexts.TXT_AUTO_REFRESH:  <input type="checkbox" name="checkBoxAutomaticRefresh" ng-model="checkBoxAutomaticRefreshValue" ng-true-value="1" ng-false-value="0" ng-change="OnCheckBoxAutomaticRefreshChange(e)">
                    | 
                    @PLanguageTexts.TXT_BOD_TIME
                  <input kendo-date-time-picker="dateTimePickerBODStart" k-ng-model="dtBODStartValue" k-options="dateTimePickerBODStart"/>
                  <input kendo-date-time-picker="dateTimePickerBODStop" k-ng-model="dtBODStopValue" k-options="dateTimePickerBODStop"/>
                </td>
            </tr>
        </table> 



                               <div kendo-grid="gridBODProductionRequests" k-options="gridBODProductionRequests(dataItem)">
                                      <div k-detail-template>
                                        <kendo-tabstrip>
                                          <ul>
                                              <li class="k-state-active">@PLanguageTexts.TXT_COMMENT</li>
                                          </ul>
                                          <div>
                                            <textarea id="BODProductionRequestsComment" class="textarea-gridComment" ng-model="dataItem.Comment" ng-change="OnCommentChange(dataItem, gridBODProductionRequests)"></textarea>
                                          </div>
                                        </kendo-tabstrip>
                                      </div>
                                </div>
                                {{dtChildStartValue}}
                          </div>  
于 2015-04-21T13:58:16.410 回答