Angular 4 - Structural directive Can't bind to X since it isn't a known property of Y -


i'm trying write structural directive remove , display components according user permissions.

this code , error recive

import { credantialsstorageservice } './_services/credantials-storage.service';  import { directive, input, templateref, viewcontainerref } '@angular/core';  import { } 'lodash';    @directive({    selector: '[accessroles]'  })  export class accessrolesdirective {    constructor(      private templateref: templateref<any>,      private viewcontainer: viewcontainerref,      private readonly credantials: credantialsstorageservice) { }        @input() set accessroles(roles: [string]) {      let isvalidarraywithroles = roles != null && array.isarray(roles) && roles.length > 0;      let isuserinoneoftheroles = isvalidarraywithroles &&           some(this.credantials.get().roles , role => roles.indexof(role) > -1);        if (isuserinoneoftheroles) {        this.viewcontainer.createembeddedview(this.templateref);      } else {        this.viewcontainer.clear();      }    }    }
  <a class="nav-item nav-link text-uppercase" routerlink="/admin" routerlinkactive="active" *accessroles="[admin]">            <i class="fa fa-question-circle"></i>            <span translate>admin</span>          </a>

error: uncaught error: template parse errors: can't bind 'accessroles' since isn't known property of 'a'

any appreicated :-)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -