Hi
Newbie!
Been trying for days to get controller to work.
My set up is using Webstorm - Angular-seed / node and I have a very basic
html page and .js file.
This is my page1.html file..
<html ng-app='myapp'>
<head>
<script src="
http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js">
</script>
<script src="controllers.js"></script>
</head>
<body>
<div ng-controller='MyCtrl'>
<p>{{characters.name}}, World</p>
</div>
</body>
</html>
I've put the .js file in controllers folder - which is....
'use strict';
angular.module('myapp')
.controller('MyCtrl', function($scope){
$scope.characters = [
{name:'fred'}
];
})
Now - if I put the following in the page1 html page with the controller
then it works.
What am I doing wrong when I try to separate the .js file from the html
page? - driving me crazy
<html ng-app>
<head>
<script src="
http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js">
</script>
</head>
<body>
<div ng-controller='MyCtrl'>
<p>{{characters}}, World</p>
</div>
<script>
var MyCtrl = function($scope){
$scope.characters = 'fred'
};</script>
</body>
</html>
Regards
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.