DavideViolante / Angular-Full-Stack

Angular Full Stack project built using Angular, Express, Mongoose and Node. Whole stack in TypeScript.
MIT License
1.49k stars 665 forks source link

Receiving JSON insted of HTML after adding route #18

Closed MojtabaGhavidel closed 7 years ago

MojtabaGhavidel commented 7 years ago

For showing problem better i created a stackoverflow question

http://stackoverflow.com/questions/41121284/angular-2-mean-stack-receiving-json-instead-of-html

DavideViolante commented 7 years ago

I think the problem is caused by the route in app.js

app.get('/dog', function(req, res) {
    Dog.find({}, function(err, docs) {
      if(err) return console.error(err);
      res.json(docs);
    });
  });

This route has the priority over the /dog route you defined in Angular (app.module file)

You should rename the route in app.js from dog to dogs (like cats)

MojtabaGhavidel commented 7 years ago

Yeah that was it. Thanks for quick response.

I suggest add a comment in that section , it's easy to miss.

Can i contribute?

DavideViolante commented 7 years ago

I don't think it's necessary :)