Issue
Error:
EXCEPTION: Error in :0:0 caused by: The selector "ng-component" did not match any elements
App works fine while running with systemjs directly. When i tried to build globals.bundle.js and app.bundle.js using webpack and deploy i get this error.
All files and dependency is loaded fine.
Here is my HTML
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Maven + Spring MVC</title>
<base href="/survey-web/">
<spring:url value="/resources/core/css/hello.css" var="coreCss" />
<spring:url value="/resources/core/css/bootstrap.min.css" var="bootstrapCss" />
<link href="${bootstrapCss}" rel="stylesheet" />
<link href="${coreCss}" rel="stylesheet" />
<%--<script src="resources/node_modules/zone.js/dist/zone.min.js"></script>
<script src="resources/node_modules/reflect-metadata/Reflect.js"></script>
<script src="resources/js/system.src.js"></script>
<script src="resources/systemjs.config.js"></script>--%>
<script src="resources/dist/globals.bundle.js"></script>
<script src="resources/dist/app.bundle.js"></script>
<script>
//System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<router-outlet></router-outlet>
</body>
</html>
Webpack config
module.exports = {
entry: {
globals: [
'zone.js',
'reflect-metadata'
],
app: './app/main.ts',
},
module: {
loaders: [
{test: /.ts$/, loader: 'awesome-typescript-loader'},
]
},
output: {
filename: '[name].bundle.js',
path: './dist'
}
};
Plunkr
https://plnkr.co/edit/AfYGsdHpIVnVnuF7BCUJ?p=preview Though it happens only in webpack build in my local environment, i can reproduce this through plnkr
Solution
Thank you @Günter Zöchbauer and @yurzui for your support
@yurzui now i understand that i need to have a selector for bootstrap component or use
<body>
<ng-component></ng-component>
</body>
instead of
<body>
<router-outlet></router-outlet>
</body>
How ever it is stange why it would work if i am using systemjs and doestn't work with plunkr or webpack.
Answered By - Jeba Prince
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.