Explain what is directive and mention what are the different types of directive?
Answer Posted / Anshuman Verma
In AngularJS, a directive is a mechanism to extend HTML vocabulary. It allows you to create custom, reusable, and extendable HTML tags. Directives can be used for creating new HTML elements, modifying existing HTML elements, or adding behavior to HTML attributes. There are four types of directives: component (class-based), function, attribute, and comment.nComponent Directive:n```typescriptn@Component({n selector: 'app-example',n templateUrl: './example.component.html'n})nclass ExampleComponent {n}n``nAttribute Directive:n```javascriptnfunction exampleDirective() {n return {n restrict: 'A',n link: function(scope, element, attrs) {n // Custom behavior heren }n }n}n``
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to use primeng in angular 4?
Angularjs dependency injection of value inside of the module.config?
How to enable html5 mode in angular 1.x?
How to implement a datagrid table with angular 2 and primeng?
How an object or function can get a hold of its dependencies?
How to get and log an error in angular 4?
What is a dynamic route in angularjs and how do you implement it?
How to create angularjs filter which outputs html?
Give the example of angularjs strings?
Which version you are using js?
What is the latest version of angular?
How can primeng be used with angular2?
What is the latest angular?