I'm learning AngularJS from W3SCHOOLS, and I am facing this problem over and over again! In the following code uncommentated lines of controller code are written by me and multiple comment lines copied from W3SCHOOLS (Angular Controllers) . When I run this program, uncommented code doesn't work, and if i use commented code instead , program works fine. I am not getting this because I am not seeing any difference between these two blocks!
<html>
<script src="angular.min.js"></script>
<script>
var app = angular.module("myApp", []);
//controller code
app.controller = ('person', function($scope){
$scope.fname = "Kiran";
$scope.lname = "Chaudhari";
$scope.fullname = function(){
return $scope.fname + " " + $scope.lname;
};
});
/*app.controller('person', function($scope) {
$scope.fname = "Kiran";
$scope.lname = "Chaudhari";
$scope.fullname = function() {
return $scope.fname + " " + $scope.lname;
};
});*/
</script>
<body>
<div ng-app="myApp" ng-controller="person">
First Name : <input type="text" ng-model="fname">
Last Name : <input type="text" ng-model="lname">
<br>
Full Name : {{fullname()}}
</div>
</body>
</html>
app.controller = (); "=" there should be no equal sign in this syntax of AngularJS