简体   繁体   English

角度cli中的未知选项-m

[英]Unknown option -m in angular cli

I want to create service and register it with app.module , but when I run this command我想创建服务并使用app.module注册它,但是当我运行此命令时

ng g s bram -m=app.module

I get an error:我收到一个错误:

Unknown option: "-m"未知选项:“-m”

在此处输入图片说明

Generate service doesn't take a module argument as services don't really “belong” to a module.生成服务不接受模块参数,因为服务并不真正“属于”模块。 To provide in root just open your service and put要在 root 中提供,只需打开您的服务并放入

@Injectable({
  providedIn: ‘root’
})

Here are the docs for service .这里是service的文档 As you can see, service does not take a module argument.正如你所看到的,服务并不需要一个模块参数。

命令尝试 Try using尝试使用

ng g s services/bram --module=app.module

The option --module is not available for a service : https://angular.io/cli/generate#service选项 --module 不适用于服务: https : //angular.io/cli/generate#service

But its available for a componant : https://angular.io/cli/generate#component但它可用于组件: https ://angular.io/cli/generate#component

I want to create service and register it with app.module , but when I run this command我想创建服务并将其注册到app.module ,但是当我运行此命令时

ng g s bram -m=app.module

I get an error:我收到一个错误:

Unknown option: "-m"未知选项:“-m”

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM