0

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

1
  • 2
    Linking to a plunker or a jsfiddle is great help, but you should also post relevant parts of your code inside your question Commented May 29, 2014 at 10:00

2 Answers 2

2

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>
Sign up to request clarification or add additional context in comments.

2 Comments

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 ?
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.
1

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

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.