What is AngularJS API and Include

AngularJS API

API is a short form of Application Programming Interface. AngularJS provides a set of APIs to use in AngularJS application.

These APIs are called as Global API. We can access these APIs using angular object. Most commonly used Global API functions are listed below:

  1. lowercase() It converts string to lowercase
  2. uppercase() It converts strings to uppercase
  3. isString() It returns true if the reference is a string
  4. isNumber() It returns true if the reference is a number

Let’s understand using one example of angular.lowercase()

Output

These APIs takes values as a parameter and after performing suitable actions, they return the result.

 

AngularJS Includes

Using AngularJS Includes, we can include HTML from external html file. We use AngularJS directive ng-include including HTML.

Let’s see an example.

Output will be browser parsed HTML written in myFile.htm.

Include AngularJS Code in external file

Actually this directive replaces associated HTML element to the HTML available in external HTML file. So we can include AngularJS code as well. The code written in external file is also executed at runtime.

Include Cross Domain HTML files

By default, AngularJS does not allow include of external files which are available in other domain. We need to add a whitelist of legal and trusted files or domains n configuration function of AngularJS application.

Output will be HTML of angular_include.asp page

 

Be Connected…

Satyendra

,

Leave a Reply

Your email address will not be published. Required fields are marked *