I use angular 1.3.19

There is a directive:

var directive = { controller: 'ProductsListController', restrict: 'A', template: ['<div class="filter-wraper">', '<div class="price-label"><span id="jprice-min">$0</span><span id="jprice-max">$5,000+</span></div>', '<input id="ex2" type="text" class="price-input" value="" data-slider-min="0" data-slider-max="5000" data-slider-step="1" data-slider-value="[0,5000]"/>', '</div>' ].join(''), link: function ($scope) { $scope.priceSliderInit = function (){ if ($(".catalog-page").length > 0) { $("#ex2").slider(); } } } 

};

It is necessary when changing the data-slider-value attribute in input to transfer the first value to span#jprice-min , and the second to span#jprice-max .

I tried to make another directive to input and then hang $observe via link , but when I try to refer to attr I get "attr. $ Observe is not a function".

Code of the second directive:

 var directive = { restrict: 'A', link: function($scope, elem, attr){ attr.$observe('value', function(newValue){ console.log(newValue); }); } }; 

Tell me, please, can there be any other solutions to this issue?

Closed due to the fact that off-topic participants Grundy , aleksandr barakin , user194374, Streletz , D-side 18 May '16 at 13:15 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Grundy, aleksandr barakin, Community Spirit, Streletz, D-side
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • add ng-model in Input, and follow the changes, or even add ng-change on the input and set variables in the handler that you then output instead of hard-coded values - Grundy
  • according to the second directive: the link function has fixed parameters: scope, element, attributes, controller - Grundy
  • @Grundy, in the second directive, corrected and corrected the attribute being tracked (value should be). But now only the first value is shown. But I can’t use ng-model because This attribute changes the jQuery plugin. - Egor
  • why can't you? :-) In the same way, the value will still be. Although you just need to try :) - Grundy
  • @Grundy, the problem is that only the value attribute is changed by the third-party plug-in in software. Those. if you attach ng-change to it, then it does not work when this attribute changes. - Egor

0