Please refer to code below.
I'd like to avoid using ng-trasclude, as it's extra wrapping elements, + ng-transclude make own scope. So my goal is to render <div foo title="FOO!">FOO!</div> in the end.
$compile(el.html())(scope) breaks, since again, it needs a wrapping element.
template: "<div ng-transclude></div>" will fail to acces scope.title.
Thanks
EDIT Added plunker link: https://plnkr.co/edit/R1CAc5pksOVMJoFLhsTu?p=preview And snippet
angular.module('app', []).directive('foo', function() {
return {
restrict: 'A',
scope: {
title: '@'
}
}
});
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.min.js"></script>
</head>
<body>
<div foo title="FOO">{{title}}</div>
<span>expecting "FOO!" above this line, but, sigh...</span>
</body>
</html>
EDIT 2
I'd like to keep isolate scope, so that attributes (<div foo title="FOO!">{{title}}</div> are then applied via scope: {title:'@'}.
EDIT 3
Updated the snippet.