【问题标题】:ngx-permissions error with directive *ngxPermissionsOnly带有指令 *ngxPermissionsOnly 的 ngx-permissions 错误
【发布时间】:2018-05-19 03:46:28
【问题描述】:

我对库 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",

我正在关注this example

我正在使用模块的版本:

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

【问题讨论】:

    标签: angular5


    【解决方案1】:

    我想说我也面临同样的问题。但就我而言;我有一个共享模块,我做了和 wiki 说的一样,但解决方案只是导出 NgxPermissionsModule。

    我的问题解决了,代码运行正常。检查你是否有同样的情况,我的修复对你有用。

    谢谢

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,我的解决方法是为子模块添加 NgxPermissionsModule

      NgxPermissionsModule.forChild()
      

      【讨论】:

        猜你喜欢
        • 2019-02-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多