Monday, 24 April 2017

How to include an Angular based theme into my node-express project

I am new to node/Angular.

So I am able to successfully implement a node project and wrote some basic service . My app.js page looks like this

 require('dotenv').load();
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var dbcon = require('./config/database');
var routes = require('./routes/index');
var app = express();

/*Node Routes*/
routes(app);


/*HTML view engine */
app.set('views', path.join(__dirname, './app/views'));
app.set('view engine', 'ejs');
app.engine('html',require('ejs').renderFile);

/*Static folder where we put client side codes*/
app.use(express.static(path.join(__dirname, 'public')));


app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());


// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

// catch 404 and forward to error handler
module.exports = app;

As you can see I am loading an HTML page in the following code

/*HTML view engine */
app.set('views', path.join(__dirname, './app/views'));
app.set('view engine', 'ejs');
app.engine('html',require('ejs').renderFile);

So inside my app/views Directory I have an index.js file where I have included some angular code which works fine.

But Now I need to include

https://github.com/flatlogic/angular-material-dashboard

this theme inide my proejct.

How should I go with it ?

Since this theme needs following command to work

gulp server

which compiles everything to some file and then it works

I am basically confused how it will work with node ?

Some suggestions would be helpful



via Vikram

No comments:

Post a Comment