Let's talk about a form:
<form name="placeThis" id="placeThis" novalidate ng-submit="submitForm();">
<input type="hidden" ng-model="placeThis.target"/>
</form>
My goal is to assign a default value to placeThis.target
from my controller. Here is how I am trying to achieve it:
$scope.placeThis = { target: 0 }
However, this doesn't seem to work unless I use $scope.$apply
or wrap it inside $timeout
(which triggers $scope.$apply
automatically).
I am able to save other $scope values from the controller without any issues, but for values within forms, I need to use $timeout
or they are not retained on submit. Can you explain why this is the case?