0

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>
2
  • What about it doesn't work? What's the difference between the expected behavior and the observed behavior? Commented Oct 19, 2014 at 19:19
  • My expression should return value "text" but it stays in HTML like {{blog}} Commented Oct 19, 2014 at 19:20

2 Answers 2

1

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

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

Sign up to request clarification or add additional context in comments.

4 Comments

But as it is written above it's from tutorial of angular so it should be valid I still don't see my mistake :(
Well that tutorial must be wrong, because app.controller = is invalid syntax.
Here is your exact code, with the controller declaration reworked to how I mention (i.e., all I did was remove the equal sign) and it works jsBin
Thank you:). you are right is there some way how to find these small bugs ?
0

Use this your controller changnge to

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.