I am using anuglar with laravel.
laravel is returning a view which includes a users id as hidden input field.
After the view is loaded I want angular to bind the userid to variable and then use it to complete a http get request to the route someotherresource/userid.
When I hard code the route to angular controller it works fine but when I try to input the variable I get an undefined error which I think is because angular is trying to fire the request before the page is fully loaded and the value has been bound to the model
app.js
function resourceController($scope, $http) {
/*$http.get('/resource' + $scope.userid).success(function(resource) {
$scope.resource = resource;
});*/
console.log($scope.userid);
}
html
<div ng-controller="resourceController">
<form>
<input type="hidden" value="1" ng-model='userid'>
</form>
%% userid %%
</div>
edit: added console.log to the js and %% userid %% to the html. this gives me undefined in the console and nothing displays for %% userid %%.
NB: I have changed the regular {{ }} syntax to %% %% to avoid conflicts the the back-end templating language.