0

Can someone tell me why the data in the scope is not getting passed to the controller.

Click on the Open Me . Add some text inside the modal window .Click Ok. why empty items are getting added?

see this Plunker

1 Answer 1

1

Use following binding instead:

<textarea class="form-control" rows="3" ng-model="$parent.currentcommitment"></textarea>
Sign up to request clarification or add additional context in comments.

2 Comments

it worked ! but tell me why i need to use $parent here .currentcommitment is defined within the same controller's scope right ?
$modal creates specific transclusion scope for its modals. So you have one more scope between template and controller. This is why $parent helps. Also you can use ng-model="currentcommitment.text" and $scope.currentcommitment = { text: "" }. Read github.com/angular/angular.js/wiki/Understanding-Scopes for more info.

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.