Constants in AngularJs

Constants can be injected everywhere including configuration calls. So when you call module.config and set up states,colors,months,weeks or other run time settings you can inject constant values.

<html ng-app="app">
<script src="Scripts/angular.min.js"></script>
<body ng-controller ="MyController">
        var app = angular.module('app', []);
        // Storing a single constant value
        app.constant('MOVIE_SAMPLE''The Movie');
        // Now we inject our constant value into a My controller
        app.controller('MyController'function ($scope, MOVIE_SAMPLE){

Constants in angularJs
Constants in AngularJs


  1. This comment has been removed by a blog administrator.


Post a Comment