2014-03-13 65 views
0

我做了一个指令为AngularJS,这是表的TD里面,这是代码:AngularJS指令传递对象错误

 <td ng-bind="order.Referencia"/> 
     <directive order="order"></directive> 
     </td> 
     <td ng-bind="order.Company"></td> 
     <td ng-bind="order.Poblacion"></td> 
     <td ng-bind="order.Direccion"></td> 
     <td ng-bind="order.Asegurado"></td> 
     <td am-time-ago="order.ImportedOn"></td> 
    </tr> 
    </tbody> 
</table> 

里面英里指令,如果我做order.file,为了是不确定的,但如果我这样做:

<tbody> 
    <tr ng-repeat="order in orders" ng-click="goToOrderDetails(order)"> 
     <td> 
      {{order.file}} 
      <directive order="order"></directive> 
     </td> 
     <td ng-bind="order.Referencia"/> 
     </td> 
     <td ng-bind="order.Company"></td> 
     <td ng-bind="order.Poblacion"></td> 
     <td ng-bind="order.Direccion"></td> 
     <td ng-bind="order.Asegurado"></td> 
     <td am-time-ago="order.ImportedOn"></td> 
    </tr> 
    </tbody> 

order.field,命令它的定义...为什么?

这是指令代码:

return { 
       restrict: 'E', 
       template: '<div></div>', 
       link: function (scope, element) { 
        span.data("alert", { 
         importedOn: order.ImportedOn 
        }); 
    //do something 
       }, 
       scope: { 
        order: '&' 
       } 
      }; 
+0

尝试从您的指令 – 2014-03-13 14:14:33

+0

中的$ scope($ scope.order ....)获取订单但我可以在链接中下订单吗?为什么如果我把这个指令放在一个新的td工作中,否则不行呢? – colymore

回答

1

在你的指令,改变范围结合描述:

scope: { 
    order: '=' 
} 

为了创建(双向)结合在一个对象父范围。