I am experiencing a problem with my custom directive that does not have a template (using server-generated DOM) and binding the view to a controller.
Check out my code snippet on jsFiddle:
angular.module('myModule', [])
.directive('myDirective', function(){
return {
bindToController: true,
controller: 'myController',
controllerAs: 'ctrl',
scope: {
text: '@'
},
}
})
.controller('myController', function($scope){
this.text = $scope.text
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.js"></script>
<div data-ng-app="myModule" data-my-directive='' data-text="Hello world!">
<h1>
{{ ctrl.text }}
</h1>
</div>
The same code works when using a string template or a template URL for my directive, but I specifically need to use the server-generated DOM.
Has anyone encountered this issue before and found a solution?
Thank you!