I am new to angularJS and trying to get the following simple samples to work. But when I ran it, I got a blank screen instead of "Hello world". Help will be greatly appreciated. Thanks.
angular-comp.js:
angular.module('myApp').component('greetUser', {
template: 'Hello, {{$ctrl.user}}!',
controller: function GreetUserController() {
this.user = 'world';
}
});
index.html:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="ISO-8859-1">
<title>AngularJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"> </script>
<script src="js/angularcomp.js"></script>
</head>
<body>
<greet-user></greet-user>
</body>
</html>
Update: I found the problem, the version 1.4.5 doesn't support component. I now use 1.6.1 and it works !!!!
angular.module('myApp', [])
instead ofangular.module('myApp')
. – Aᴍɪʀ 23 hours ago