我正在尝试创建一个指令来在我的Angular JS应用程序中运行Stellar JS插件。
这就是我的想法:
app.directive('stellar', function() {
return function (scope, element, attrs) {
element.stellar({
parallaxBackgrounds: true
})
}
});并像这样使用它:
<div stellar></div>我做错了什么?
我在控制台中没有得到错误...
发布于 2013-09-19 06:36:12
我不知道stellar,但我知道你有一个通过directives :):https://github.com/Pleasurazy/angularjs-stellar使用它的AngularJS插件
我认为你应该使用它,使用现有的库或插件总是更好。
希望能有所帮助
不管怎样,试试这个:
app.directive('stellar', function() {
return {
link: function (scope, element, attrs) {
element.stellar({
parallaxBackgrounds: true
})
}
}
});你必须返回一个在AngularJS指令中实现“链接”或“编译”函数的对象。有关更多信息,请阅读文档:http://docs.angularjs.org/guide/directive
https://stackoverflow.com/questions/18882847
复制相似问题