Angular (2/4) something similar to Symfony (2/3) tagged services -


i'm trying achieve similar symfony's tagged services.

what going used for: want reproduce "voters" front-logic (yes, im aware frontend technology not going give me 100% sure of real permission, that's reason need such logic "translate" backend frontend).

what want on success: signle service contains array of configured services (by constructor, setter or whatever). best possibility use module in sub-module(s) using forchild static method, service contain voters both main & sub module(s).

what i've done far: i've created provider in module

export const permission_voters = new injectiontoken<permissioncheckerservice>('permissioncheckerservice');  @ngmodule({...}) export class securitymodule {     /**      * @param {array<ipermissionvoter>} config      * @returns {modulewithproviders}      */     static forroot (config: {voters: array<type<ipermissionvoter>>} = {voters: []}): modulewithproviders {         return {             ngmodule:  securitymodule,             providers: [                 <classprovider>{                     useclass: permissioncheckerservice,                     provide:  permission_voters,                     usevalue: config,                     multi:    true                 }             ],         };     } } 

then, i've created permissioncheckerservice, , isgrantedcomponent

somehow, i've managed instance of permissioncheckerservice isgrantedcomponent can't understand, why array of voters empty, if provide them follows:

    securitymodule.forroot({         voters: [userpermissionvoter]     }), 

i'm afraid missunderstood documentation somewhere (were reading documentation , trying compare "similar" logic 3rd party lib's).


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -