我在尝试通过http.get获取本地HTML文件时获得404。无法解决问题。代码/筛选作物:
组件:
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Rx';
//
// Resembles the view for creating and editing card visuals and metadata.
//
@Component({
selector: 'cards',
templateUrl: './cards.component.html',
styleUrls: ['./cards.component.css']
})
export class CardsComponent implements OnInit{
constructor(public http: Http) { }
defaultCards: any = [
{
name: 'Default',
frontUrl: './templates/default/front.html',
backUrl: './templates/default/back.html'
}
];
ngOnInit() {
this.http.get('./templates/default/front.html').subscribe(
(res) => console.log(res.json()),
(error) => console.log(error));
}
}
控制台日志404.非常感谢任何帮助。