1

I'm trying to bind a ng-model this way:

      <md-list-item ng-repeat="reply in replies">
        <md-input-container flex style="margin-top:-7px;" ng-show="replyLink">
          <label>Your reply ...</label>
          <input ng-model="replyMsg" ng-enter="addReply(reply.id)">
        </md-input-container>
      </md-list-item>

From the other side:

 $scope.replyMsg...

Using this, when I change the value of one ng-model and log the content of replyMsg, I get undefined as output message. How do I fix that?

I've tried to make it ng-model="replyMsg{{$index}}", but, I wasn't able to find out how to deal with this model name in the other side using $scope.

Any brilliant suggestion?

2 Answers 2

1

you can do it in this way . every reply will contain their reply msz.

<md-list-item ng-repeat="reply in replies">
        <md-input-container flex style="margin-top:-7px;" ng-show="replyLink">
          <label>Your reply ...</label>
          <input ng-model="reply.replyMsg" ng-enter="addReply(reply.id)">
        </md-input-container>
      </md-list-item>
Sign up to request clarification or add additional context in comments.

9 Comments

it still the same. I think that is because that there are multiple inputs binding with the same ng-model. Is there another alternative?
$scope.reply.replyMsg, I've got undefined as output message.
have you typed anything before accessing ??
yes, and after that I've pressed on the Enter key.
after filling first input do like this $scope.replies[0].replyMsg
|
0

I made simple plunker of that hope this helps.

`http://plnkr.co/edit/OUqh5l1omH9Tgv6xAyBO?p=preview`

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.