0

Here is my form

<form>
<input class="text_box1" type="text" name="email" ng-model="forget.email" >
<button style="width:auto" class="sign_up" ng-click="doForget(forget)">Get a Password</button>
</form>

Inside my app.js I have

.when('/forget', {
                title: 'forget',
                templateUrl: 'resources/views/forget.php',
                controller: 'authCtrl'
            })

And inside the authCtrl controller i tried to do the console of the input value.

$scope.doForget = function (customer) {
        console.log($scope.email);
    };

But i am getting the console as undefined always.

How can i get this value ?

8
  • 1
    Typo. ng-model is forget.email and you are outputting $scope.email Commented Jul 2, 2015 at 2:11
  • What is the result of: console.log(customer);? Commented Jul 2, 2015 at 2:11
  • @PSL While i do console.log(forget.email); i am getting error ReferenceError: forget is not defined Commented Jul 2, 2015 at 2:15
  • @user5071852 that is because it is not defined. It will be a property on the scope. Also what is on the property that you are passing in as customer? Commented Jul 2, 2015 at 2:15
  • @Hackerman If i do console.log(customer); i am getting the $scope.forget() in the console Commented Jul 2, 2015 at 2:15

2 Answers 2

2

No need to define email just

$scope.forget={};

And get a value in controller by

$scope.forget.email
Sign up to request clarification or add additional context in comments.

Comments

1

First define folowing in your controller

$scope.forget={
email:'',
}

After that you can get the value by

$scope.doForget = function (customer) {
        console.log($scope.forget.email);
    };

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.