Angularjs隔离范围动态传递属性名称

时间:2013-12-26 12:49:05

标签: angularjs angularjs-directive

我正在尝试制作一个从控制器数据中制作carousal的指令

这是我的

----------控制器---------

myApp.controller('myCtrl', function($scope){

                $scope.outfit = {
                    name : 'guess',
                    price : '100$'
                };

                $scope.myLook= {
                    name : 'guess',
                    price : '100$'
                };

                $scope.tabs = [
                    { title:"THE RUNWAY" , data : 'outfit'},
                    { title:"MY LOOK",  data : 'myLook'},
                ];
    );

------我的指示--------

myApp.directive('bxSlider',function(){
     return {
          restrict : 'E',
          templateUrl : require.toUrl('../partials/bxSlider.html'),
          replace: true,
          scope: {
                outs : "="
          }
    }
});

------我的模板--------

<div ng-controller="myCtrl">
    <div ng-repeat="tab in tabs">
       <bx-slider outs="{{ tab.data }}" /> 
        // i want my outs param value as the output of tab.data as param 
        // i.e outfit or mylook  **how can i do that is there any workaround**
    </div>
</div>

jsfiddle link

1 个答案:

答案 0 :(得分:0)

它的工作检查出来。我更改了scope variable的{​​{1}} Fiddle Sample