I add DOM element (externally to Angular), $compile it and link it with scope in directive's event handler - controller defined in ng-controller of new element fires up, but databinding is not working - the result is
{{data.name}}
like it's not compiled at all ... Why? (I use $compile for the first time so, maybe I'm missing something)
Below is just directive's code:
app.directive('pages', function ($compile) {
return {
restrict: 'E',
link: function (scope, element) {
element.on('pageLoaded', function(event){
var page = angular.element(event.detail.element);
var linkFn = $compile(page);
scope.data = {
name: 'DATA SET IN DIRECTIVE'
};
linkFn(scope);
});
}
}
});
Page I add (dom element in event.detail.element) is
<div page="AddedPage" ng-controller="PageController">
{{data.name}}
</div>
Here is jsfiddle: http://jsfiddle.net/yoorek/EYCwY/