Ezequiel Ramiro Ezequiel Ramiro - 3 months ago 33
Ruby Question

How can I pass my current_user.id to AngularJs Controller

I'm getting my current_user.id from Ruby on Rails and trying to pass it to my angular controller through HTML hidden input>

<input type="hidden" ng-model="user_id" value="<%= current_user.id%>"></input>

Debugging, my scope is undefined for "$scope.user_id", and I need this value to send it to my server.

Am I doing something wrong? Is there a better way?



<input type="hidden" 
       ng-init="user_id = <%= current_user.id%>"></input>