Skip to main content

Posts

Showing posts with the label create and inject the constants in AngularJs

Constants in AngularJs

Hello everyone, I am going to share the code sample for " how to create the constants in AngularJs ? " and " how to inject in angular controller? ". The defined constants are ready to use by angular controller as give below. /**  * @angular root module.  */ var app = angular.module( 'myConstantApp' ); /**  * @ The constants defined in myServiceConst are ready for use by controller.  */ app.constant( 'myServiceConst' ,            { blankMsg: "Please enter your service’s number."  ,              numLessGraterThen10 : 'put msg' }); /**   * Controller using constants.   * @ng-Inject : my   myServiceConst  is going to inject by the linkToMyServices contoller.  */ app.controller( 'linkToMyServices' , function ($scope, myServiceConst) {        /**      * @Initialize t...