【发布时间】:2019-03-12 13:45:35
【问题描述】:
在step by step dev 之后,我正在尝试隐藏未经授权的按钮。
这是按钮的代码,在 phoneBook.component.html 中:
<button *ngIf="'Pages.Tenant.PhoneBook.CreatePerson' | permission" class="btn btn-primary" (click)="createPersonModal.show()"><i class="fa fa-plus"></i> {{l("CreateNewPerson" | localize)}}</button>
当我运行项目时,我在控制台中收到该错误:
ERROR Error: "Uncaught (in promise): Error: Template parse errors:
The pipe 'permission' could not be found ("
</div>
<div class="col-sm-6 text-right">
.......
我该如何解决这个问题?
【问题讨论】:
-
您之前是否在代码中创建过管道?
-
你在
*.module.ts中声明了管道吗? -
不,我没有创建管道,也没有在 *.module.ts 中声明它。我只是按照一步一步开发
-
见Angular - Pipes 该页面某处注明:
You must include your pipe in the declarations array of the AppModule.