Question: I am trying to bind the ng-model parameter which was initially set in a controller back to the controller 
I have something like this 

```
    <div ng-app="myApp" ng-controller="personCtrl">

     First Name: <input type="text" ng-model="firstName"><br>
     Last Name: <input type="text" ng-model="lastName"><br>
      </div>

    <script>
        var app = angular.module('myApp', []);
        app.controller('personCtrl', function($scope) {
        $scope.firstName = "Leo";
        $scope.lastName = "Messi";

        });
    </script> 

```

I am trying to implement a PUT method in my controller, so I needed to bind the new value back to the controller . I tried 

```
        <div ng-app="myApp" ng-controller="personCtrl">
        <form>
         First Name: <input type="text" ng-model="firstName"><br>
         Last Name: <input type="text" ng-model="lastName"><br>
         <button ng-click="UpdateProfile()"> Update </button>
         </form>
         </div>

```

then in I updated my controller to

```
       <script>
        var app = angular.module('myApp', []);
        app.controller('personCtrl', function($scope) {
        $scope.firstName = "Leo";
        $scope.lastName = "Messi";
        $scope.UpdateProfile = function()
           {
               $scope.newFirstName = firstName
           }
        });
    </script>  

```

But I got an error saying firstName is not define.

any help would be appreciated

Answer: 
It should be:

```
$scope.UpdateProfile = function()
    {
        $scope.newFirstName = $scope.firstName;
    }
});

```
Your Code - you have attached firstName to the $scope variable which is an object internally and and firstName is its property.

For example if I create a sample testApp module with testController and attach a property test1 to it and console log the $scope variable.
then i can see whole $scope object in console.
// Code goes here

```
var app =angular.module('testApp',[]);
app.controller('testController',testController);
testController.$inject=['$scope'];

function testController($scope){
  $scope.test1="plunkr";
  console.log($scope);
}

```

[![$scope object containing test1 property](https://i.stack.imgur.com/Bg3xy.png)](https://i.stack.imgur.com/Bg3xy.png)

so you should access firstName as a property of $scope object not as a variable firstName
so your code should be

```
 $scope.firstName = "Leo";
    $scope.UpdateProfile = function()
               {
                   $scope.newFirstName = $scope.firstName
               }
       });

```

<https://plnkr.co/edit/zJ3X3XP9N1C0oZlvZ7mh?p=preview>