panelApp.directive('batModelTree', function ($compile) { // make toggle settings persist across $compile var modelState = {}; var scopeState = {}; return { restrict: 'E', terminal: true, scope: { val: '=', edit: '=', inspect: '=' }, link: function (scope, element, attrs) { // this is more complicated then it should be // see: https://github.com/angular/angular.js/issues/898 element.append( '
' + 'Scope ({{val.id}})' + ' | scopes' + ' | models' + '
' + '' + '
' + '
' + '
' + '' + '
' + '
' + '
'); var childScope = scope.$new(); childScope.modelState = modelState; childScope.scopeState = scopeState; $compile(element.contents())(childScope); } }; });