2015-01-06 30 views
1

我的指令是以下角指令解釋屬性作爲字符串

angular 
    .module('app.directives') 
    .directive('myTable',function(){ 

     function linkFn(
      scope, 
      element, 
      attrs 
      ) { 

      console.log(attrs.attributes); 

     } 

     return { 
      link: linkFn, 
      template: 'some.html', 
      scope: { 
       attributes: '=', 
      }, 
      replace : true 
     } 
    }); 

而且我用的,而不是指令,因爲

<my-table attributes="management.table.attributes"></my-table> 

然而,在鏈接功能的attrs.attribute值解析字符串management.table.attributes,是一個數組。

我會很感激任何形式的幫助或指導。

謝謝!

回答

1

attrs.attribute總是會是一個字符串,因爲屬性是字符串的定義。您需要相應的scope.attributes這是將被評估的對象參考:

console.log(scope.attributes);