0

The following little Angular App works using 1.2.26 but not with 1.3.0.

<!DOCTYPE html>
<html>
<head>
    <!--<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js"></script>-->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js"></script>

<script>
    function MyController() {
        this.data = {
            txtHello: "Hello"
        };
    }

</script>

</head>


<body ng-app ng-controller="MyController as controller">

<p><input ng-model="controller.data.txtHello"></p>

<p>Text: {{controller.data.txtHello}}</p>

</body>
</html>

Databinding seems not to work... Why? Any advice?

Jack
  • 125
  • 1
  • 2
  • 7
  • 1
    It's not about data binding not working. Your controller doesn't get picked up. If you look in the console, you'll see the error: `Error: [ng:areq] Argument 'MyController' is not a function, got undefined`. Hint: *Always* watch the console. – Ates Goral Oct 22 '14 at 15:29

1 Answers1

-1

In the AngularJS 1.3 release you are not longer able to declare global functions you musr register them with the inline syntax, for example:

angular.module('yourApp',[]).controller('MyController', ['$scope', function($scope){

}])
Dima Grossman
  • 2,800
  • 2
  • 21
  • 26