Why doesn't Angular 2 load the default root application component?

I am trying to run an Angular application generated using the Angular CLI, but it looks like the component is app-rootnot loading by default . I must say that I use a proxy to connect between the Angular application and the express server, and at the same time I run two scripts: node bin/wwwfor express / node.js start and ng serve --proxy-config proxy.config.jsonfor starting with Angular and creating a proxy connection, it looks like this (part of package.json ):

"scripts": {
  "start": "concurrently --kill-others \"node bin/www\" \"ng serve --proxy-config proxy.config.json\""
}

The index page loads fine, but it seems that the component app-root(the default component that was created from the Angular CLI ng new) does not load: enter image description here Here is my node.js / express useand route:

var express = require('express');
var router = express.Router();
var app = express();
var path = require('path');

app.use(express.static('./src/client/'));
app.use(express.static('./'));
app.use(express.static('./tmp'));
app.use('/*', express.static(path.resolve('src/client/index.html')));

router.get('*', function(req, res) {
    res.sendFile(path.resolve('src/client/index.html'));
});

module.exports = router;

And the structure of my project (if necessary): enter image description here

? app-root ? ( , ng serve Angular , - , , - ).

+6
1

dist/ ng build --prod ( --prod, --dev). , :

"scripts": {
  "start": "ng build --prod && node bin/www"
}

, script:

app.use(express.static('./dist'));
app.use('/*', express.static(path.resolve('dist/index.html')));

router.get('*', function(req, res) {
    res.sendFile(path.resolve('dist/index.html'));
});
+5

All Articles