Yeoman - Angular Material 部分 html 模板在 grunt 构建后未正确加载
Yeoman - Angular Material partial html template are not correctly loaded after grunt build
我使用 Yeoman 作为项目启动器制作了一个 Angular Material 网络应用程序。当我运行
grunt serve
我可以在本地主机中正确看到该网站,一切正常。
当我 运行:
grunt build
构建我的 Web 应用程序,它完成时没有任何错误。
之后,我将 dist 文件夹内容上传到我的在线网络服务器,但是当我导航到网络应用程序时,我在 $mddialog 中使用的部分模板 html 没有加载,我得到这个错误:
GET http://my.website.url/views/dialogs/dialoginfodocument.html 404 (Not Found)
on file vendor.t3fefw.js
$mddialog 代码是:
$mdDialog.show({
scope: $scope,
templateUrl: './views/dialogs/dialoginfodocument.html',
parent: angular.element(document.body),
targetEvent: $event,
clickOutsideToClose:true,
preserveScope:true,
useFullScreen: useFullScreen
})
和部分模板 html:
<md-dialog>
<md-toolbar>.....</md-toolbar>
<md-dialog-content>....</md-dialog-content>
</md-dialog>
我做错了什么?
感谢 charlietfl 评论,我解决了这个问题。
问题是 html 模板 url 之前的前导 ./
。
我使用 Yeoman 作为项目启动器制作了一个 Angular Material 网络应用程序。当我运行
grunt serve
我可以在本地主机中正确看到该网站,一切正常。 当我 运行:
grunt build
构建我的 Web 应用程序,它完成时没有任何错误。 之后,我将 dist 文件夹内容上传到我的在线网络服务器,但是当我导航到网络应用程序时,我在 $mddialog 中使用的部分模板 html 没有加载,我得到这个错误:
GET http://my.website.url/views/dialogs/dialoginfodocument.html 404 (Not Found)
on file vendor.t3fefw.js
$mddialog 代码是:
$mdDialog.show({
scope: $scope,
templateUrl: './views/dialogs/dialoginfodocument.html',
parent: angular.element(document.body),
targetEvent: $event,
clickOutsideToClose:true,
preserveScope:true,
useFullScreen: useFullScreen
})
和部分模板 html:
<md-dialog>
<md-toolbar>.....</md-toolbar>
<md-dialog-content>....</md-dialog-content>
</md-dialog>
我做错了什么?
感谢 charlietfl 评论,我解决了这个问题。
问题是 html 模板 url 之前的前导 ./
。