我试图在Angular中设置范围广播。 Datetimepicker应该在父网格中定义,子节点应该继承它。我试过这种方式:
$scope.dtBODStopValue = new Date()
$scope.dtBODStartValue = new Date(new Date(new Date().getTime() - 7 * MS_PER_DAY));
更改日期/时间并广播到其他网格
$scope.dateTimePickerBODStart = {
change: function () {
$scope.$broadcast(dtBODStartValue,dtBODStopValue);
$scope.OnGridRefresh();
}
};
$scope.dateTimePickerBODStop = {
change: function () {
$scope.$broadcast(dtBODStartValue,dtBODStopValue);
$scope.OnGridRefresh();
}
};
HTML:
<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"/>
答案 0 :(得分:1)
根据文件$ broadcast是范围方法
$scope.$broadcast(name, args);
所以在你的情况下它应该是
$scope.$broadcast('datepickerUpdate', dtBODStartValue, dtBODStopValue);
然后是child
范围内的听众
$scope.$on('datapickerUpdate', function (event, dtBODStartValue, dtBODStopValue) {
//do stuff on change
})