Getting an error when using ng-controller in angularjs ver 1.3.0 [duplicate]

in angular 1.3.0 u have to do like below, Because Global controllers were disabled in 1.3.0-beta. reference

<div ng-app="myApp" ng-controller="personController">

<script>
var app = angular.module("myApp",[]);

app.controller('personController', function($scope){
     $scope.firstName = "David";
     $scope.lastName = "Silva";
})
</script>

It also said that you can get the older behavior by using below code , but its not recomended

<div ng-app="myApp" ng-controller="personController">

var app = angular.module("myApp",[]).config(['$controllerProvider', function($controllerProvider) {
     $controllerProvider.allowGlobals();
}]);

function personController($scope) {
    $scope.firstName = "David";
    $scope.lastName = "Silva";
}

Leave a Comment