Artur
Artur

Reputation: 33

angularjs error argument 'controller' is not a function got undefined

Hello I've been searching for reason why my code doesn't work but i can't find it. I've found similar question posted here but non help. This is my code.

<!DOCTYPE html>
<html ng-app="app"> 
    <head>
        <meta charset="utf-8">
        <title>AngularJs tests</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
    </head>
    <body ng-controller="Ctrl">
        <input type="text" ng-model="blog"><br>

        <br>

        {{blog}}
<script>
    var app=angular.module('app',[]);
    app.controller=('Ctrl', ['$scope',function($scope){
        $scope.blog="text";
    }]);
</script>
    </body>
</html>

Upvotes: 0

Views: 1323

Answers (2)

Harutyun Abgaryan
Harutyun Abgaryan

Reputation: 2023

Use this your controller changnge to

var app=angular.module('app',[]);
    app.controller('Ctrl', ['$scope',function($scope){
        $scope.blog="text";
    }]);

Upvotes: 0

Tom
Tom

Reputation: 7740

app.controller = ( ... ); is not valid syntax.

app.controller('Ctrl', ...);

Upvotes: 1

Related Questions