var myApp = angular.module('myApp', []);
myApp.controller('someController', function($scope) {
$scope.click = function(){
alert("Hello there!");
};
});
myApp.directive('testInput',function(){
return {
restrict: 'E',
replace: false,
transclude: false,
template: '<div>Custom directive content</div>',
controller: function($scope) {
}
};
});
HTML:
<div ng-app = "myApp" ng-controller = "someController">
<div class = "clickme" ng-click ="click()">
Click me
</div>
<div id="container">
</div>
</div>
Is there a way in Angular to dynamically append the directive (testInput) to #container without using JQuery? Check out this JSFiddle for an example: http://jsfiddle.net/4L6qbpoy/1/