Please help me on, How can we make AngularJS compile the code generated by directive ?
You can even find the same code here, http://jsbin.com/obuqip/4/edit
<
Here's a version that doesn't use a compile function nor a link function:
myApp.directive('helloWorld', function () {
return {
restrict: 'E',
replace: true,
scope: {
myUsername: '@'
},
template: 'Hello {{myUsername}}'
+ 'Sorry, No user to greet!',
};
});
Note that the template is wrapped in a because a template needs to have one root element. (Without the , it would have two The HTML needs to be modified slightly, to interpolate: Fiddle.