Here is an example of my email verification link:
.when('/user/register/verify/:verify_code?', {
controller: 'AngularRegisterVerifyPage',
templateUrl: '/user/register/verify'
})
This is how my input field is set up:
input(ng-model="formData.verify_code", name="verify_code", type='text', class='form-control', placeholder='Verification Code', id="verify_code")
The code below should execute when the template loads to insert the parameter into the text field:
document.getElementById('verify_code').value = "Test"; // Debugging Test Code
$scope.formSubmitted = false;
if ($routeParams.hasOwnProperty("verify_code")) {
document.getElementById('verify_code').value = $routeParams.verify_code;
}
However, it seems like the controller runs this before the template actually loads because the input field is empty when the page loads. I am looking for guidance on how to properly achieve this functionality. I have tried researching solutions like "Load Template after Controller loads" without success. Thank you.
Edit:
I attempted adding ng-init="loadCode()"
to the input field but it did not solve the issue.
$scope.loadCode = function() {
if ($routeParams.hasOwnProperty("verify_code")) {
console.log('Called');
document.getElementById('verify_code').value = $routeParams.verify_code;
console.log($routeParams.verify_code);
console.log(document.getElementById('verify_code').value);
}
}