1

The expression is not getting updated with value I type in text box.

<html>
    <head>
        <title>Angular Test</title>
        <meta charset="UTF-8">
        <script src="angular.js" type="text/javascript"> </script>
        <script>
           var app=angular.module("myApp",[]);
           app.controller("ctrl",function($scope){
                $scope.name="asdfsdf";
           });
        </script>
    </head>
    <body ng-app="myApp" ng-controller="ctrl" >
        <input type="text" ng-bind="name" /> {{name}}
    </body>
</html>

2 Answers 2

1

Change ng-bind to ng-model.....ng-model provides two-way binding where as ng-bind provides only one-way binding.

<html>
    <head>
        <title>Angular Test</title>
        <meta charset="UTF-8">
        <script src="angular.js" type="text/javascript"> </script>
        <script>
           var app=angular.module("myApp",[]);
           app.controller("ctrl",function($scope){
                $scope.name="asdfsdf";
           });
        </script>
    </head>
    <body ng-app="myApp" ng-controller="ctrl" >
        <input type="text" ng-model="name" /> {{name}}
    </body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

0

Change the ng-bind to ng-model to update the value of input.

<html>

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
  <title>Angular Test</title>
  <meta charset="UTF-8">
  <script src="angular.js" type="text/javascript">
  </script>
  <script>
    var app = angular.module("myApp", []);
    app.controller("ctrl", function($scope) {
      $scope.name = "asdfsdf";
    });
  </script>
</head>

<body ng-app="myApp" ng-controller="ctrl">
  <input type="text" ng-model="name" />{{name}}
</body>

</html>

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.