我有一个需要向子控制器广播的刷新功能。我在父控制器中做了这样的事情:
// 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>