Johnathan Mackney Johnathan Mackney - 5 months ago 84
AngularJS Question

EJS.JS ReferenceError: title not defined

I am having an issue with a script in express. I am calling a function that renders a view, on the success of another function. In this project I am utilizing angular, node, express, and ejs as view engine. When I render the view, I unfortunately receive an ejs error of the following:

ReferenceError: /Users/emilywfrancis/Desktop/nodejs-angularjs-sequelizejs/views/about.ejs:5

3| <html ng-app="app">

4| <meta charset="utf-8">

5| <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/3.1.0/css/font-awesome.min.css" />

6| <% include header %>

7| <% include navbar %>

8| <body>
title is not defined


Here is the code:

exports.verifyusers= function(req, res) {
models.user.find({
where: {
email: req.body.email,
password: req.body.password
}
}).then(function(res, user) {
if(user == "user.name") { //if user exists in database
res.render('/about')
};
});
};

Answer

Seems like the error is actually in the header file which proprely contains something like:

<%= title %>

I think changing changing it to the following will work:

<%= (typeof title != "undefined" ? title : "") %>
Comments