Without knowing anything about scroll spy, here's how you generally want to use a JQuery plugin in Angular:
app.directive('scrollSpy', function (){
return {
restrict: 'A',
link: function(scope, elem, attr) {
elem.scrollSpy({ /* set up options here */ });
//watch whatever expression was passed to the
//scroll-spy attribute, and refresh scroll spy when it changes.
scope.$watch(attr.scrollSpy, function(value) {
elem.scrollSpy('refresh');
});
}
};
});
Then in HTML:
<div scroll-spy="foo">Do something with: {{foo}}</div>
The above example is VERY generic, but it will basically apply your plugin to an element, and call 'refresh' or whatever on it every time $scope.foo changes.
I hope that helps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…