Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You don't want to manipulate the DOM (or even reference it) from your controllers.</p> <p>A directive is best here.</p> <pre class="lang-js prettyprint-override"><code>app.directive('revealModal', function (){ return function(scope, elem, attrs) { scope.$watch(attrs.revealModal, function(val) { if(val) { elem.trigger('reveal:open'); } else { elem.trigger('reveal:close'); } }); elem.reveal(); } }); </code></pre> <p>then in your controller:</p> <pre class="lang-js prettyprint-override"><code>$scope.modalAddWidget = function (){ $scope.ui = { add_widget_value: '' }; $scope.showModal = true; }; $scope.addWidget = function (){ $scope.myobject.widgets.push({"name": $scope.ui.add_widget_value}); $scope.ui.add_widget_value = ''; $scope.showModal = true; }; </code></pre> <p>And in your HTML</p> <pre class="lang-html prettyprint-override"><code>&lt;div class="button" ng-click="modalAddWidget()"&gt;Add Widget&lt;/div&gt; &lt;div id="modalAddWidget" class="reveal-modal" reveal-modal="showModal"&gt; &lt;h6&gt;New Widget&lt;/h6&gt; &lt;form name="addWidgetForm" ng-submit="addWidget()"&gt; &lt;fieldset&gt; &lt;legend&gt;Widget Name&lt;/legend&gt; &lt;input type="text" name="widgetValue" ng-model="ui.add_widget_value" required /&gt; &lt;span ng-show="addWidgetForm.widgetValue.$error.required"&gt;required&lt;/span&gt; &lt;/fieldset&gt; &lt;button type="submit" class="small button right"&gt;Add Widget&lt;/button&gt; &lt;div class="small button right secondary" ng-click="showModal = false;"&gt;Cancel&lt;/div&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>Basically you'd set a boolean in your scope to show and hide your modal. (I'm not sure of reveal modal's open/close mechanism, so I'm guessing in my code above).</p> <p>ALSO: I went through the effort of adding some validation in there.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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