简体   繁体   中英

Unknown option -m in angular cli

I want to create service and register it with app.module , but when I run this command

ng g s bram -m=app.module

I get an error:

Unknown option: "-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

@Injectable({
  providedIn: ‘root’
})

Here are the docs for 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

But its available for a componant : https://angular.io/cli/generate#component

I want to create service and register it with app.module , but when I run this command

ng g s bram -m=app.module

I get an error:

Unknown option: "-m"

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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