我正在创建一个基于角度的Web应用程序,用户可以使用html / css / javascript创建html应用程序。 在那里,我想实现一个预览功能。除了一个错误之外,一切都很完美。它无法加载链接的javascript文件。
我的网络应用程序项目文件夹结构如下所示
project
|
|-app -> apps -> dev
| |
| |-> App1 ->html -> index.html
| | ->javascript -> myfile.js
| |
| |-> App2 ->html -> index.html
| | ->javascript -> myfile.js
|
|-index.html
在我的主index.html文件中,有一个ng-view。应该在这个div中加载所有应用程序。 路线配置正确完成。但是,当我加载App1时,它会渲染index.html文件,但会出现此错误。
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:6406/javascript/myfile.js?_=1404039101044
Uncaught SyntaxError: Unexpected token < localhost:6406/#/dev/App1:1
app1的index.html
<html>
<body>
<script src="../javascript/myfile.js"></script>
<h1>This is App1.</h1>
</body>
</html>
我在路由配置时添加了以下if语句。
when('/dev/:name', {
templateUrl: function (name) {
console.log(name);
return '/app/apps/dev/' + name.name + '/html/index.html';
}
})
myfile.js如下所示。
alert("Hello");
alert('world');
有人能指点我如何让App1加载myfile.js吗?