我对库 ngx-permissions 的指令有问题。这些是我的 angular 依赖项的版本:
"@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",
Run Code Online (Sandbox Code Playgroud)
我正在关注这个例子。
我正在使用模块的版本:
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 { }
Run Code Online (Sandbox Code Playgroud)
我可以毫无问题地使用这些服务,但只有指令出错。错误是下一个:
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
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,我的解决方法是为子模块添加NgxPermissionsModule。
NgxPermissionsModule.forChild()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5228 次 |
| 最近记录: |