angular.module('myApp')
    .factory('permissions', function ($rootScope) {
        var permissionList;
        return {
            setPermissions: function(permissions) {
                permissionList = permissions;
                $rootScope.$broadcast('permissionsChanged');
            },
            hasPermission: function (permission) {
                permission = permission.trim();
                if(permissionList.indexOf(permission) < 0)
                    return false;
                else
                    return true;
            }
        };
    });

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js