Note that there are some explanatory texts on larger screens.

plurals
  1. POScope issue in AngularJS using AngularUI Bootstrap Modal
    text
    copied!<p>plunker: <a href="http://plnkr.co/edit/wURNg8ByPYbEuQSL4xwg">http://plnkr.co/edit/wURNg8ByPYbEuQSL4xwg</a></p> <p><strong>example.js:</strong></p> <pre><code>angular.module('plunker', ['ui.bootstrap']); var ModalDemoCtrl = function ($scope, $modal) { $scope.open = function () { var modalInstance = $modal.open({ templateUrl: 'modal.html', controller: 'ModalInstanceCtrl' }); }; }; var ModalInstanceCtrl = function ($scope, $modalInstance) { $scope.ok = function () { alert($scope.text); }; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; }; </code></pre> <p><strong>index.html:</strong></p> <pre><code>&lt;!doctype html&gt; &lt;html ng-app="plunker"&gt; &lt;head&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.js"&gt;&lt;/script&gt; &lt;script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"&gt;&lt;/script&gt; &lt;script src="example.js"&gt;&lt;/script&gt; &lt;link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet"&gt; &lt;/head&gt; &lt;body&gt; &lt;div ng-controller="ModalDemoCtrl"&gt; &lt;button class="btn" ng-click="open()"&gt;Open me!&lt;/button&gt; &lt;div ng-show="selected"&gt;Selection from a modal: {{ selected }}&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>modal.html:</strong></p> <pre><code>&lt;div class="modal-header"&gt; &lt;h3&gt;I'm a modal!&lt;/h3&gt; &lt;/div&gt; &lt;textarea ng-model="text"&gt;&lt;/textarea&gt; &lt;div class="modal-footer"&gt; &lt;button class="btn btn-primary" ng-click="ok()"&gt;OK&lt;/button&gt; &lt;button class="btn btn-warning" ng-click="cancel()"&gt;Cancel&lt;/button&gt; &lt;/div&gt; </code></pre> <p>Why I can't get the $scope.text defined in ModalInstanceCtrl, even though I can use $scope.ok and $scope.cancel?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload