So I basically want to be able to trigger an event and then have a directive compile and insert its self to a position in the DOM. Currently I have something like this
You have to create the dom element first, then compile it and add it to the document. Something like this:
$scope.$on('insertItem',function(ev,attrs){
var chart = angular.element(document.createElement('chart'));
var el = $compile( chart )( $scope );
//where do you want to place the new element?
angular.element(document.body).append(chart);
$scope.insertHere = el;
};
I've created a simple example here: http://plnkr.co/edit/n7SZpyeQ9nbjVSYA7ibB?p=preview