I have a dynamically generated form with a time field which is filled in with angular-moment-picker
. I want this value to be copied to the other time fields using a function assigned to ng_change
. Currently this function is not called however my input field includes ng_change
. When I don't use moment-picker
then value is copied without any issues.
input field:
@Html.TextBoxFor(model => model.Mymodels.Model[i].Time,
new
{
@class = "form-control",
ng_Model = "Model_Time" + (i + 1),
ng_change = "copyTime(" + (i + 1) + ")",
moment_picker = "Model_Time" + (i + 1),
format = "LT",
locale = "nl",
ng_model_options = "{ updateOn: 'blur' }",
set_on_select = true
})
Copy function:
$scope.copyTime = function (index) {
console.log("Check if function is called");
$scope.Model_Time2 = $scope.Model_Time1;
$scope.Model_Time3 = $scope.Model_Time1;
$scope.Model_Time4 = $scope.Model_Time1;
};
According to the docs, it has its own function called
change
:That said, if angular-moment is using
ngModelController
underneath to update the model, I'd have expectedng-change
to work as well since it is invoked automatically once the model has changed. Maybe it doesn't play nice withng-model-options
?