I'm trying to write a test directive that just shows some markup on the web page. For some reason, when I try to update the markup using AngularJS's angular.element() function, it only shows a visual representation of the object. Much like viewing a JavaScript object from the browser.
[[object HTMLInputElement], [object HTMLSpanElement], [object HTMLBRElement]]
This is my template page where I am just spitting out the directive, it's too simple.
<div my-sample></div>
My directive looks like this,
eventsApp.directive('mySample', function ($compile) {
var markup = '<input type="text" ng-model="sampleData" /> {{ sampleData }} <br />';
return {
link: function (scope, element, atts, controller) {
angular.element(element).html($compile(markup)(scope));
}
}
});
What am I doing wrong?