NGX-验证误差,带有指令 *ngxpermissionsonly



我在库ngx-permissions的指令中有问题。这些是我角度依赖的版本:

    "@angular/animations": "^5.0.3",
    "@angular/common": "^5.0.3",
    "@angular/compiler": "^5.0.3",
    "@angular/core": "^5.0.3",
    "@angular/forms": "^5.0.3",
    "@angular/http": "^5.0.3",
    "@angular/platform-browser": "^5.0.3",
    "@angular/platform-browser-dynamic": "^5.0.3",
    "@angular/router": "^5.0.3",

我正在遵循此示例。

我正在使用模块的版本:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgxPermissionsModule } from 'ngx-permissions';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    // Specify your library as an import
     NgxPermissionsModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

我可以毫无问题地使用服务,但是我只有指令才有错误。错误是下一个:

Can't bind to 'ngxPermissionsOnly' since it isn't a known property of 'div'. ("
    </div>
            </div>
                <div [ERROR ->]*ngxPermissionsOnly="['ADMIN', 'GUEST']" class="m-portlet__head-tools">
                    <ul class="nav nav-pil"): ng:///DashboardModule/DashboardComponent.html@35:10
Property binding ngxPermissionsOnly not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("
                    </div>
                </div>
                [ERROR ->]<div *ngxPermissionsOnly="['ADMIN', 'GUEST']" class="m-portlet__head-tools">
                    <ul class="nav na"): ng:///DashboardModule/DashboardComponent.html@35:5

我遇到了相同的问题,我的修复程序是添加 ngxpermissionsmodule for Child Module。

NgxPermissionsModule.forChild()

我想说我也面临同样的问题。但就我而言;我有一个共享的模块,我做的与Wiki所说的相同,但解决方案只是出口ngxpermissionsmodule。

我的问题出去了,代码正常工作。检查您是否有相同的情况,我的修复程序适合您。

谢谢

最新更新