I need angularjs controller to read hidden input field on a form. I tried to define a scope variable in the controller 'postData.TransactionId' and look at this in the controller. But the value is coming as blank. Is it because DOM is not loaded yet for angularjs controller to look at the input field? Are there any alternatives? Thank you!
<form name="form1" id="form1" ng-controller="Ctrl">
<input type="hidden" id="TransactionId" name="TransactionId" value="@Request.Form["TransactionId"]" ng-model="postData.TransactionId">
</form>
I am trying to inject a service in the script tag of the view but I get an error saying "angular is undefined". Is it possible to read the value in Ctrl this way?
<div ng-controller="Ctrl">
</div>
<script src="~/Scripts/angular-idle.min.js"></script>
<script>
var app = angular.module('pay', []);
app.service("PostService", function () {
this.TransactionID = "Test";
});
</script>