I would like to try using this directive:
我想尝试使用这个指令:
appModule.directive('scrollpane', function ($compile) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.addClass('scroll-pane');
element.jScrollPane();
var api = element.data('jsp');
scope.$watch(function () { return element.find('.' + attrs.scrollpane).length }, function (length) {
api.reinitialise();
});
}
};
});
I think I already correctly added the jQuery and other scripts. Can someone tell me how I would call this?
我想我已经正确地添加了jQuery和其他脚本。有人能告诉我怎么称呼这个吗?
2 个解决方案
#1
1
Assuming you want to use this on a DIV:
假设你想在DIV中使用它:
<div scrollpane>Contents...</div>
The restriction to 'A' means you want to use your directive as an attribute.
“A”的限制意味着您希望将您的指令用作属性。
#2
1
I'm assuming that the appModule
is your main module.
我假设appModule是你的主模块。
You can see on line 3 that this directive is restrict to an attribute (restrict: 'A'
).
您可以在第3行看到该指令限制于一个属性(限制:“A”)。
So, all you have to do is create a html element with this attribute.
因此,您所要做的就是用这个属性创建一个html元素。
<div scrollpane></div>
#1
1
Assuming you want to use this on a DIV:
假设你想在DIV中使用它:
<div scrollpane>Contents...</div>
The restriction to 'A' means you want to use your directive as an attribute.
“A”的限制意味着您希望将您的指令用作属性。
#2
1
I'm assuming that the appModule
is your main module.
我假设appModule是你的主模块。
You can see on line 3 that this directive is restrict to an attribute (restrict: 'A'
).
您可以在第3行看到该指令限制于一个属性(限制:“A”)。
So, all you have to do is create a html element with this attribute.
因此,您所要做的就是用这个属性创建一个html元素。
<div scrollpane></div>