Reputation: 83
I'm trying to create module and controller for understanding the basic concept. I tried below code but it does not work.
<div ng-contoller = "MyController">
<p>
{{ author.name }}
</p>
<p>
{{ author.age }}
</p>
<p>
{{ author.sex }}
</p>
</div>
var myApp = angular.module('myApp',[]);
myApp.controller('MyController', function MyController($scope){
$scope.author = {
'name' : 'Sameer Sashittal',
'age' : '28',
'sex' : 'Male'
}
});
Above code is not working. Can any one guide me where i'm doing wrong.
Upvotes: 3
Views: 220
Reputation: 17289
Remove MyController
. It should be like this.
var myApp = angular.module('myApp',[]);
myApp.controller('MyController', function($scope){
$scope.author = {
'name' : 'Sameer Sashittal',
'age' : '28',
'sex' : 'Male'
}
});
Upvotes: 2
Reputation: 41387
add you module using ng-app
to the div.
Also there is typo error in the ng-controller
<div ng-app="myApp" ng-controller = "MyController">
the controller should be
myApp.controller('MyController', function ($scope){
Upvotes: 2