What would be more efficient/a better practise: binding multiple object properties to different scope properties or binding the whole object to the scope and accessing the properties in the template.
Here are some examples of both scenarios:
Single object binding:
directive('info', [function(){
return {
scope: {
object: "="
},
restrict: 'E',
template: '<div>\
<div>{{ object.something }}</div>\
<div>{{ object.something2 }}</div>\
<div>{{ object.something3 }}</div>\
<div>{{ object.something4 }}</div>\
<div>{{ object.something5 }}</div>\
</div>',
replace: true
};
}]);
<info ng-repeat="info in infoArray" object="info"></info>
Multiple bindings:
directive('info', [function(){
return {
scope: {
something: "=",
something2: "@",
something3: "@",
something4: "=",
something5: "@",
},
restrict: 'E',
template: '<div>\
<div>{{ something }}</div>\
<div>{{ something2 }}</div>\
<div>{{ something3 }}</div>\
<div>{{ something4 }}</div>\
<div>{{ something5 }}</div>\
</div>',
replace: true
};
}]);
<info
ng-repeat="info in infoArray"
something="info.something"
something2="info.something2"
something3="info.something3"
something4="info.something4"
something5="info.something5">
</info>