Атрибуты могут передаваться так же, как мы передаем директивы типа E.
См: http://plnkr.co/edit/T2R91F0iR9GfttSav9Zq?p=preview
//HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-example12-production</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-app="docsSimpleDirective">
<div ng-controller="Controller">
<div my-customer customer="customer" testv="Hello"></div>
</div>
</body>
</html>
//JS
(function(angular) {
'use strict';
angular.module('docsSimpleDirective', [])
.controller('Controller', ['$scope', function($scope) {
$scope.customer = {
name: 'Naomi',
address: '1600 Amphitheatre'
};
}])
.directive('myCustomer', function() {
return {
restrict: 'A',
scope: {
customer:'=',
testv: '@'
},
template: 'Name: {{customer.name}} Address: {{customer.address}} - {{v1}}',
link: function(scope, element, attrs) {
console.log(attrs);
scope.v1=attrs.testv;
}
};
});
})(window.angular);