The code below where I create a controller within index.htmls <script></script>
doesn't work. What is wrong here? I do know I can make it work by having a separate app.js
and define there. But interested to know why this doesn't work.
<!DOCTYPE html>
<html data-ng-app>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div data-ng-controller="SkillsController">
<ul>
<li data-ng-repeat="skill in skills">{{skill.name}} - {{ skill.stars}}</li>
</ul>
</div>
<script>
function SkillsController($scope) {
$scope.skills = [
{ name: 'Ruby', stars: 5 },
{ name: 'Java', stars: 10}
];
}
</script>
<script type="text/javascript" src="js/angular.js"></script>
</body>
</html>