Angular: Directive Modify Parent Scope

http://angularjs.org/

by Bretto

HTML

<script src="http://code.angularjs.org/angular-1.0.0rc8.js"></script>
<script type="text/ng-template" id="MyInclude.html">
 <div>test: {{ test }}, other: {{other}}</div>         
</script>  

<script type="text/ng-template" id="MyDirective.html">
<div>
    <div>test: {{ test }}, other: {{other}}</div>
    <hr />
    <div>
        <div ng-include="'MyInclude.html'"></div>
    </div>
</div>         
</script>

<div ng-controller="MyParent">
    outside: {{title}}
    <my-element test="Hello?" other="title"></my-element>
</div>

JavaScript

var myApp = angular.module('myApp',[]);

myApp.directive('myElement', function(){
    return {
        restrict: 'E',
        replace: true,
        inject: {
            'test': 'attribute',
            other: 'accessor'
        },
        templateUrl: 'MyDirective.html',
        controller: 'MyDirective'
    }
});
    
function MyDirective($scope, test, other)
{
    console.log( arguments, this, test );
    $scope.test = test
    $scope.other = other()
    other('asd')
}

function MyParent($scope) {
    $scope.title = 'World'
}