2

I am using angular to build a waitinglist-system, where you first join a waitinglist, and then can be moved to the memberlist. I use ng-repeat to fill inn the table with the rows of waiting people, and I assign a button to each row, which can be pressed to move that particular person to the memberlist.

First problem: I am not sure if i assign the value to the button in the correct way. It is supposed to be the email of the person.

<input type="submit" ng-click="makeMember()" ng-model="member" value="Member" id="{{person.email}}">

Second problem: I want to use this users email in order to make a sql query to send to the database to move the person to the memberlist (email is primary key).

I am trying to use $scope.member to reference the ng-model, but that only gives me an undefined value.

The makeMember function is just to see if it works (which it doesnt).

$scope.makeMember = function() {
    alert("Person email: " + $scope.member);
};

Any help is highly appreciated!

0

1 Answer 1

2

Pass member in like this: ng-click=makeMember(member).

$scope.makeMember = function(member) {
    alert("Person email: " + member);
};

Live demo here (click).

The issue you are having is that $scope refers to the controller's scope, not the child scope created by ng-repeat. The only way $scope.member would work is if you had defined it in the controller.

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

1 Comment

Wow, that was quick, and it works! Thank you very much!

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.