fal*_*off 2 angularjs angularjs-directive
我为我的应用程序编写通用滑块指令,我需要指定例如HTML代码中的控件按钮,如下所示:
<div class="slide-wrapper" data-sample-values="{prevbtn: '.previous', nextbtn: '.next'}"></div>
Run Code Online (Sandbox Code Playgroud)
作为对象属性,我如何将这些值作为指令获取?
或者也许有另一种方法来做可恢复指令?我如何从父范围中隔离这些元素?
myApp.directive('slideWrapper', function() {
return {
restrict: 'C',
scope: { getValues: '&sampleValues' }, // creates an isolate scope
link: function(scope, element, attrs) {
var values = scope.getValues(); // evaluates expression in context of parent scope
...
}
}
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3466 次 |
| 最近记录: |