Is it possible to pass angularjs variable to a nodejs function from view like below
// View
<div ng-repeat="user in users">
<img src="<%getUserImage(user)%>">
</div>
// Server
app.locals.getUserImage = function (user) {
if (user.url) { return user.url; };
return "/images/no-user.png";
}
I have the following error: Cannot read property 'url' of undefined
Can anyone help please ?
Thank you
Why don't you perform this operation in the view instead of having to call the server function?
Just like this
<img ng-src="{{ user.url || '/images/no-user.png' }}"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.