I am trying to fetch whatever I type inside modal; on main body, but it is not happening, somehow one way data binding is running. Here's my plunker : http://plnkr.co/edit/sKAGGVQVStudrmtka72p?p=preview
2 Answers
Alternative solution:
http://plnkr.co/edit/tgP06wRuZmAdJMmPR8So?p=preview
change ok function to take a parameter:
$scope.ok = function (take_me_outside) {
console.log($modalInstance);
$modalInstance.close(take_me_outside);
};
and use it in the template like
<button class="btn btn-primary" ng-click="ok(take_me_outside)">OK</button>
2 Comments
Moose
It worked thanks a lot, But can you please explain me, why we are using it in template : ng-click="ok(take_me_outside)" ? Also if i want to print message (in javascript like alert or console.log();) where can it be done ?
Quad
we changed the ok function to take a parameter, so we pass the required parameter on ng-click function. you can either log/alert it in ok function or the model instance's .then callback.
Can be fixed when using an object on `$scope' and binding the ng-model to this object. In your case, you can use the following:
$scope.modalForm = {};
$scope.modalForm.take_me_outside = "asdfasdf";
Update this structure where required in the code, and it will work. I updated the plunker for you, check out the working version: http://plnkr.co/edit/XGU1rY650MsbvZ2fcqgJ?p=preview