Note that there are some explanatory texts on larger screens.

plurals
  1. POIsolate scope value not being passed to controller
    primarykey
    data
    text
    <p>I am using <a href="https://github.com/prajwalkman/angular-slider" rel="nofollow">angular-slider.js</a> on a page that makes a server request when the value of the slider changes. I don't want this to happen until the user has let go of the mouse button, in other words onmouseup.</p> <p>This is pretty easy to do in a directive using the '=' isloate scope and passing this to a scope variable.</p> <p>However, the same thing in angular-slider doesn't behave as I would expect.</p> <p>In the html I have added the attribute 'mousewatch', which is assigned the $scope variable 'mouseStatus'</p> <pre><code>$scope.mouseStatus = 0; &lt;slider floor="0" ceiling="10" ng-model-low="pMinBedsVal" ng-model-high="pMaxBedsVal" mousewatch="mouseStatus"&gt;&lt;/slider&gt; </code></pre> <p>... and added this to the directive as an isolate scope:</p> <pre><code> sliderDirective = function($timeout) { return { restrict: 'EA', scope: { floor: '@', ceiling: '@', step: '@', precision: '@', ngModel: '=?', ngModelLow: '=?', ngModelHigh: '=?', translate: '&amp;', mousewatch: "=" }, </code></pre> <p>...finally I have added the values of mousewatch to the onEnd and onStart events in the slider directive:</p> <pre><code> onEnd = function() { pointer.removeClass('active'); scope.mousewatch = 0; console.log("mouseup"); ngDocument.unbind(events.move); return ngDocument.unbind(events.end); }; onStart = function(event) { pointer.addClass('active'); scope.mousewatch = 1; console.log("mousedown"); dimensions(); event.stopPropagation(); event.preventDefault(); ngDocument.bind(events.move, onMove); return ngDocument.bind(events.end, onEnd); }; </code></pre> <p>The problem is that the value set for scope.mousewatch in the directive is not passed to $scope.mouseStatus in the controller.</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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