How to organize simple authorization on AngularJs? I googled, but found nothing suitable. Share screencasts / articles. Thank.

  • As far as I understand, authorization occurs on the server. How do you see angular authorization? - Stepan Kasyanenko

1 answer 1

If you want to use basic auth , then for the beginning it will be more convenient for you to work with the library for encoding in base64. For example this .

After connecting this library, you will need to add http header to the config

 angular .module('myApp', ['base64']) .config(function($httpProvider, $base64) { var auth = $base64.encode("foo:bar"); $httpProvider.defaults.headers.common['Authorization'] = 'Basic ' + auth; }) 

You can read more in the article .