-3
I need to declare all the error message like (401,200 etc....) in a property file, need to access them later where ever its required

in the below format mostly 

key=messsage
404 = This request caon't be processed
200 = your request is successfull

Is it posssible in angular ifso could any body give me an idea, thank u

======================================================================

user1245524
  • 285
  • 1
  • 8
  • 18

1 Answers1

0

I think ... it is possible. lol !

You can declare global value via JSON file. (keep it on your server)

See the JSON format here.

Example:

globalvalue.json

[
  {
    "key": 404,
    "message": "This request caon't be processed"
  },
  {
    "key": 200,
    "message": "your request is successfull"
  }
]

And next you just read that global value via your server it store the JSON file.

Angular Code:

angular
.module('app.services', [])
.factory('Friend', function ($http) {
    return {
        get: function () {
            return $http.get('/globalvalue.json');
        }
    };
});

Then use your factory this way:

.angular
.module('app.controllers', ['app.services'])
.controller('yourCtrl', function ($scope, Friend) {
    Friend.get().then(function (msg) {
        $scope.msg = msg;
    });
});

Cr. Reading data from JSON file in Angularjs.

let's fun. :)

Community
  • 1
  • 1