BetaRide
BetaRide

Reputation: 16834

Simple angular component doesn't show anything

I'm trying to implement a very simple Angular component. I expect it to output "Hello World" for the main-windows tag. Unfortunately it's not showing anything.

I can confirm, that webpack is working fine. I can see all my files packed in bundle.js and there are not errors.

index.html:

<!DOCTYPE html>
<html>
<head lang="en">
    <title>Test Page</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body ng-app="prj">

<main-window></main-window>

<script src="bundle.js"></script>

</body>
</html>

index.js:

import 'expose?$!expose?jQuery!jquery';
import angular from 'angular';
import 'bootstrap-webpack';
import './mystyle.css';
import './mainWindow.js'

var ngModule = angular.module('prj', []);

mainWindow.js: import angular from 'angular';

angular.module('prj', []).component('mainWindow', {
        template: '<h1>Hello World</h1>'
    }
);

Upvotes: 3

Views: 3827

Answers (1)

Sampath
Sampath

Reputation: 65860

Please try as shown below.

index.js

var ngModule = angular.module('prj', []);

mainWindow.js

ngModule.component('mainWindow', {
        template: '<h1>Hello World</h1>'
    }
);

Upvotes: 1

Related Questions