0

I get undefined for my logInModel when passing it in ng-click function. however when i use debugger i can see my properties are populating with value.

can someone explain to me please?

    $scope.logInModel = {
        userName: "",
        password: ""
    };

    $scope.postLogin = function (logInModel) {
        console.log("logInModel " + logInModel);
        authService.postLogin(logInModel).then(successCallback, errorCallBack);
    }


<div>
    <div class="row">
        <span>
            User Name:&nbsp;
            <input type="text" name="txtUserName" ng-model="logInModel.userName" />
        </span>
    </div>
    <div class="row">
        <span>
            Password:&nbsp;
            <input type="password" name="txtUserName" ng-model="logInModel.password" />
        </span>
    </div>
    <div class="row">
        <span>
            <button type="submit" name="btnSubmit" ng-click="postLogin(loginmodel)">
                <span> Sign In</span>
            </button>
        </span>
    </div>


</div>

3 Answers 3

1

The casing is wrong in the ng-click. Use an upper case "I" and "M" ... As in logInModel

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

1 Comment

Thank you, didnt know it was case secretive
1

You are passing postLogin(loginmodel) in your view, however in your $scope, it is logInModel, with a capital I and M that's why it is undefined.

Comments

0

Your passing parameter is wrong. It should be ng-click="postLogin(logInModel)"

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.