How do you write a directive?



How do you write a directive?..

Answer / Uma Kaushik

To write a custom AngularJS directive, you define an object with properties for template, restrict, replace, scope, controller, compile, link, and priority. For example:nn```javascriptnmyApp.directive('myDirective', function() {n return {n restrict: 'E', // Element selectorn template: '<div>Custom Directive!</div>',n link: function(scope, element, attrs) {n // Linking function logic heren }n };n});n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More AngularJS Interview Questions

What is the name of directive is used to bootstrap an angular app?

1 Answers  


What types of pipes are supported in angular 2?

1 Answers  


What are the main features of angularjs?

1 Answers  


How to achive in angular ?

1 Answers  


How to handle xss vulnerability scenarios in angularjs?

1 Answers  


Explain what a digest cycle is in angularjs?

1 Answers  


How to create & call angular 2 services in components?

1 Answers  


What is karma and jasmine?

1 Answers  


What is key value pipe in angular 7?

1 Answers  


What is the meaning of ng in angular 2?

1 Answers  


How to use styleurls and styles in angular?

1 Answers  


What do you mean by ng-app,ng-init,ng-model?

1 Answers  


Categories