Hi everybody,
We have a mover type directive. I noticed, that if I move all items from the left to the right or vs. versa using the buttons, the form's dirty state is not changing and therefore when I click Cancel button on the form I don't get a prompt for unsaved changes.
So, I want to programmatically set its dirty state.
My problem is that I can not figure out how to refer the form (or that control) from the directive.
I tried the following code in the MoveRightAll button:
$scope.moveRightAll = function() {
var unassignedItems = $scope.unassignedItems.slice(0);
var items = $scope.unassignedItems.slice(0);
angular.forEach(items, function (value, key) {
$scope.assignedItems.push(value);
removeItem(unassignedItems, value);
});
$scope.unassignedItems = unassignedItems;
$scope.form.$setDirty(); // my bad attempt
$scope.unassigned = {};
};
and it didn't work. I can see that there is no form for the scope variable.
So, how can I access the form which is hosting my directive to set its dirty flag?
Thanks in advance.
If it's not broken, fix it until it is.
My Blog