AngularJS login form separated from ng-app -
good morning, i'm creating dashboard in angularjs lot of features. site multi user application every user login before using it. angularjs can define 1 ng-app , 1 ng-view, need have template login pages (login, lost password, onboarding wizard etc) , template dashboard pages appears afer succefull login (user managing, settings). utilize token authentication. how can accomplish task? i'm triyng hide elements header , left menu when user not logged in doesn't seem solution.
first can have multiple ng-app in single page. have manual bootstrapping. first ng-app automatically bootstrapped angular. take @ stack overflow discussion
angularjs multiple ng-app within page
for adding authorization token requests, have utilize interceptors. here illustration code interceptor book 'angularjs , running'
angular.module('notesapp', []).factory('authinterceptor', ['authinfoservice', '$q', function(authinfoservice, $q) { homecoming { request : function(config) { if (authinfoservice.hasauthheader()) { config.headers['authorization'] = authinfoservice.getauthheader(); } homecoming config; }, responseerror : function(responserejection) { if (responseerror.status === 403) { // authorization issue, access forbidden authinfoservice.redirecttologin(); } homecoming $q.reject(responserejection); } }; }]).config(['$httpprovider', function($httpprovider) { $httpprovider.interceptors.push('authinterceptor'); }]);
angularjs
No comments:
Post a Comment