2017-04-26 83 views
3

我更新了我的项目,并且Angular 2和现在4中的一切都很好。现在我带了Angular-CLI 1.0.0和它不会找到primeNG的json文件。错误:Uncaught(承诺):状态响应:404升级到Angular-CLI + Angular 4时未找到URL

constructor(private http: Http) {} 

    getFiles() { 
     return this.http.get('mock_data/data.json') 
      .toPromise() 
      .then(res => <TreeNode[]> res.json().data) 
      .then(data => { return data; }); 
    } 

抛出的错误,我尝试添加一个./复制到仔细检查该文件夹的路径。

在我index.html文件我有<base href="/">和目录下src

错误:

core.es5.js:1084 ERROR Error: Uncaught (in promise): Response with status: 404 Not Found for URL: http://localhost:4200/mock_data/data.json 

enter image description here

+0

有什么错误? – echonax

+0

你能分享你的文件夹结构吗?像截图 – echonax

+0

@echonax完成.. – Drew1208

回答

1

尝试移动mock_dataassets文件夹,然后用'assets/mock_data/data.json'更新网址。


建议编辑:

另一种方式:添加"mock-data".angular-cli.json文件:

"assets": [ 
      "assets", 
      "favicon.ico", 
      "mock-data" 
     ] 
相关问题