为什么我的角度2应用程序不呈现?
我有一个角2应用程序,我在观看视频教程时正在构建。但问题是我很好地引用了这些文件,但我在浏览器的控制台中找不到页面。 这里是我的组件为什么我的角度2应用程序不呈现?
@Component({
moduleId: module.id,
selector: 'my-employee',
templateUrl: '.Employee/employee.component.html'
})
export class EmployeeComponent {
firstName: string = 'Mr X';
lastName: string = 'Johnson';
gender: string = 'Male';
age: number = 20;
}
的templateUrl被正确引用的代码,但我仍然得到页NOF发现错误。请任何帮助将非常欢迎。谢谢。 UPDATE:结构工程
你好能不能请你:
templateUrl: './employee.component.html'
这是路径问题。您不需要在teamplateURL
中添加员工。
下面是完整的代码:
@Component({
moduleId: module.id,
selector: 'my-employee',
templateUrl: './employee.component.html'
})
export class EmployeeComponent {
firstName: string = 'Mr X';
lastName: string = 'Johnson';
gender: string = 'Male';
age: number = 20;
constructor() {
}
}
您好@Izuagbala,如果您使用此解决方案得到解决,请将答案标记为已接受。 –
我试过你发布的解决方案,但问题仍然存在。我得到 http:// localhost:59956/src/app/Employee/employee.component.html 404(Not Found) http:// localhost:59956/src/app/Employee/employee.component.html;区域:
感谢您的回答有帮助。我现在已经解决了这个问题。 – Izuagbala
由于employee.component.html和employee.component.ts都在同一个文件夹,然后无需添加雇员/ employee.component.html模板URL路径。你也只使用'。'在文件夹名称之前,请将其更改为'./employee.component.html'
。希望ut会起作用。
你可以发布你的项目结构吗? –
我刚做粗略的更新找不到更好的方式来更新项目结构。 – Izuagbala
我正在谈论项目结构的截图。 –