Ответ 1
Вам нужно использовать '='
для сопоставления объекта. '@'
подразумевает, что вы просто передаете строковое значение в новую область.
app.directive('myDirective', function () {
return {
restrict: 'E',
scope: {
site: '=', //two-way binding
index: '@' //just passing an attribute as a string.
},
template: '<div>{{site}}</div>',
replace: true,
}
});
Затем в вашей разметке не используйте привязку в атрибуте, просто передайте выражение:
<div id="eventGraphic" class="span12">
<!-- below, site="site" is passing the expression (site) to
the two way binding for your directive scope,
whereas index="{{$index}}" is actually evaluating the expression
($index) and passing it as a string to the index attribute,
which is being put directly into the directive scope as a string -->
<my-directive ng-repeat="site in IEvent.sites"
site="site"
index="{{$index}}"></my-directive>
</div>