Looking to use This Plunker example code to dynamically add elements to an HTML page using AngularJS. (Make sure to run it in a separate link, not in the editor environment.) This will be my first time working with AngularJS Directives (aside from simple testing). I have a couple of questions regarding this code snippet:
- I typically use the
Controller as
syntax instead of$scope
in my controllers. What changes should I make to the sample code above since it uses$compile(...)($scope)
? - Is the scope in a Directive related to the controller? If I can remove the scope reference from the controller in this scenario, do I need to make any adjustments to the directive?