Pages

Sunday, 8 November 2015

How to declare the Constants in the Angular JS

In this post we are going to see how to create a constants in angular js. Any programming language have declaration of constants, because it can be used any where with out change in the value. likewise we can use the constants in the Angular JS

From the above example you can see the Version and Name are declare as constant inside a method , it can be access using the instance Application. Later the Constant is injected in to the controller and access the variable which is required from the package. Now inside the Maincontroller it is assigned in the new variables and uses in the Footer tag.In the above code i interpolated the symbol to [[ ]] from {{ }}, that is why the expression is written as like that [[Name]] @ [[Version]]Output:************Angular Sample @ 1.0.0.0From this post you can learn how to use the constants in angular js.