What are ng-include and ng-click directives in AngularJs?

ng-include helps to include different files on the main page. The ng-include directive includes HTML from an external file.

The included content will be included as child nodes of the specified element. The value of the ng-include attribute can also be an expression, returning a filename.

By default, the included file must be located on the same domain as the document.

<div ng-include="'myFile.htm'"></div>

ng-click can be used in scenarios like when you click on a button or when you want to do any operation. It tells AngularJS what to do when an HTML element is clicked.

Example:

<button ng-click="count = count + 1" ng-init="count=0">OK</button>

The above code will increase the count variable by one whenever the button is clicked.

Top 50+ Angular Interview Questions with Answers

Angular is one of the most current web development frameworks around the world.  In almost every interview, you will have… Read More

4 years ago