slavayancheg
slavayancheg

Reputation: 59

Can't add view as html page (sails.js)

Good day.

I create a new sails.js project, create new controller (FooController), create model (Foo), in configuration file as view engine setted 'ejs', i create action that show list of Foo, in index.ejs view, add route for this view, but i cannot add details.html for detail view, in routes.js, error 'Ignore attempt to bind route ...', sails.js doesn't understand html file.

'/': {
    view: 'home/index'
},

'/foo': {
    view: 'foo/index'
},

'/fooDetails': {
    view: 'foo/details.html'
}

Please explain how to add html page to application as view? Or it is impossible?

And give some link where i can get some experiense about sails.js and sails.js features.

Thank you.

Upvotes: 1

Views: 3643

Answers (2)

Chris McCormick
Chris McCormick

Reputation: 4456

To serve an html page from the assets folder directly you can do this in config/routes.js:

'/fooDetails': function(req, res, next) {
    res.sendfile(sails.config.appPath + '/assets/foo/details.html');
}

Upvotes: 8

Madra David
Madra David

Reputation: 151

Why do you want to directly pass a file with .html extension , why not just

'/fooDetails': {
    view: 'foo/details'
}

And then paste all your html in details.ejs ?

Upvotes: 1

Related Questions