gpt4 book ai didi

angular5 - ngx-permissionsOnly 指令错误

转载 作者:行者123 更新时间:2023-12-02 15:04:30 36 4
gpt4 key购买 nike

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

最佳答案

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

NgxPermissionsModule.forChild()

关于angular5 - ngx-permissionsOnly 指令错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47654349/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com