Reputation: 119
Not sure why is this not working
<body ng-app="main" id="homepage">
<h1 ng-controller="homepageCtrl">hello {{test}}</h1>
</body>
JS
var app = angular.module("main", [])
.controller("homepageCtrl", function($scope) {
$scope.test = "World!";
});
Upvotes: 2
Views: 47
Reputation: 3095
Your code is fine. It's the jsfiddle which was creating the trouble.
Switch the load type from onLoad
to No Wrap - in <head>
Just tested it on your fiddle. Works like a charm.
Why it works?
JsFiddle wraps the code in a ready or load event by default & Angular may not get what it needs in the global scope when compiling your code. No wrap in <head>
just loads the script in the head, without a wrap.
Give this a read if you use jsfiddle a lot for Angular, it'll save you a lot time- Using jsFiddle with Angular
Upvotes: 1