我在里面重复了几千个项目,所以我决定试用结合地来减少手表的数量。但我想不出如何正确地使用它。现在我得到了以下代码:
<div ng-repeat="card in cards">
<div class="item-box" draggable="{{card.category}}" itemId="{{card._id}}">
<img ng-src="{{card.image}}" width="100%" height="100%">
</div>
</div>正如我在宾登医生中所读到的,我应该添加这个指令并使用bo-*指令,因此我解释了以下内容:
<div ng-repeat="card in cards" bindonce>
<div class="item-box" draggable="{{card.category}}" itemId="{{card._id}}">
<img bo-src="card.image" width="100%" height="100%">
</div>
</div>那么,我的问题是,我如何也可以使用{{card.category}}和{{card._id}}使用绑定-一次?
bo-attr bo-attr-draggable="card.category" bo-attr-itemId="card._id"好像不工作,我没有任何错误,只是什么都没发生。
结果就像
<div class="item-box ng-scope" bo-attr="" bo-attr-draggable="card.category" bo-attr-itemid="card._id" draggable="Pants" itemid="m--Pi">发布于 2014-02-06 02:53:40
bo-attr看起来并不像你想要做的那样,你只是想要一个指令来评估和绑定数据,而不需要创建任何手表。我做了一个我认为是你想要的:http://plnkr.co/edit/sFPAjlRCkDuXU5UiM1U1?p=preview
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});
// html
<div directive="name"></div>
// Dummy directive
app.directive('directive', function() {
return {
template: '<div bindonce bo-text="val"></div>',
compile: function() {
return {
pre: function(scope, elt, attrs) {
scope.val = scope.$eval(attrs.directive);
}
};
}
}
})不许看手表!
如果我误解了什么,请告诉我。
https://stackoverflow.com/questions/21592042
复制相似问题