javascript - How to pass data from EJS template to AngularJS controller -
i've got user info expressjs through nodejs following:
app.js
app.get('/user', function(req, res) { res.render('users', { title: 'foo', user: req.user }); });
users.ejs
<%= user %>
i need user
info user.ejs
above angularjs controller, display on other named views.
could help me it?
some ng-init feels dirty , wrong me. can set inline , mess window , rootscope can messy. or can inline module like:
<script> angular.module('preloadeddata', []) .constant('user', <%- user %>); </script>
then available other dependency.
javascript node.js angularjs express ejs
No comments:
Post a Comment