Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 无法在中加载build/toastr.min.css_Angular - Fatal编程技术网

Angular 无法在中加载build/toastr.min.css

Angular 无法在中加载build/toastr.min.css,angular,Angular,我正在尝试在我的angular应用程序中使用toastr api。但它不会加载 我使用了npm安装--save toastr来导入库 页面组件 constructor(private fb: FormBuilder,private backend:WebsiteBackendService,private toastr:ToastrService) { this.mouseOverSubmit = false; } submit(formValues) { this.

我正在尝试在我的angular应用程序中使用toastr api。但它不会加载

我使用了npm安装--save toastr来导入库

页面组件

constructor(private fb: FormBuilder,private backend:WebsiteBackendService,private toastr:ToastrService) {
    this.mouseOverSubmit = false;
   }

  submit(formValues) {
    this.toastr.success("Form Submitted!");
    this.backend.submitBlogArticle(this.form.getRawValue()).subscribe((data:any) => {
      //this is where a response would come in
      console.log(data);
    });
    console.log(this.form.getRawValue());
  }
Json

 "styles": [
  "src/styles.css",
  "node_modules/toastr/build/toastr.min.css"
 ],
 "scripts": [
   "node_modules/toastr/build/toastr.min.js"
 ]
应用程序模块

  providers: [
    ResolveService,
    ToastrService
  ],
toastr服务

import { Injectable } from '@angular/core'

declare let toastr:any;
@Injectable()
export class ToastrService {
    success(message:String,title?:string) {
        toastr.success(message,title);
    }
}
我已经根据我在下面评论中看到的内容进行了编辑,但问题仍然存在。

angular.json文件

"styles": [
  "src/styles.css",
  "node_modules/toastr/build/toastr.min.css"
 ],
 "scripts": [
   "node_modules/toastr/build/toastr.min.css" // <-- remove it
 ]

在angular.json的“脚本”部分添加toastr.min.js而不是toastr.min.css

此外,您不需要在html本身中添加toastr链接,因为它可以从angular.json文件中获得

"styles": [
    "src/styles.css",
    "node_modules/toastr/build/toastr.min.css"
]