I have this crazy idea, I'm building an app with different contents to show, and the contents' data is from the server with websocket, also the directives for showing the data.
So I'm wondering if there is a way I could dynamically generate/register directives at runtime?
Like, I put an directive like this:
<content ng-repeat="d in data" ></content>
and then after I got the directive from the server, I could using something like this to register this:
angular.module('app').directive('content', function(){
return {
restrict: 'E',
template: // some way to fetch the template
...
}
And then if the user enter this view, angular will be loading the directive I just registered.
Also, I've tried several ways, like
<div ng-include="'some template'" ng-repeat="d in data"></div>
that works if all you need to do is repeat some plain html. But not if you're trying to bind some data too.