angularjs - AngularJS 1.7 - templateUrl 在视图中显示 url 而不是模板
问题描述
概括
我正在尝试将我的 angularjs 组件/指令转换为 TypeScript。不幸的是,该templateUrl
属性不显示传递给它的模板。相反,它实际上显示了模板的部分路径。
代码
class JumpPagerController {
...
}
}
JumpPagerController.$inject = ['$timeout'];
export const jumpPagerComponent = {
templateUrl: './jump-pager.component.html',
controller: JumpPagerController,
bindings: {
pagerPlaceholder: '@?',
pagerCurrentPage: '=',
pagerItemsPerPage: '=',
pagerTotalItems: '=',
pagerChange: '&'
}
};
预期的
实际的
我试过的
- 传入baseUrl(这里没有寄予厚望:
templateUrl: `${baseUrl}/jump-pager.component.html`
templateUrl: localhost:8080/jump-pager.component.html
template: require('...')
有效,但需要我重新配置 webpack,然后修改所有其他templateUrl
in.js
文件。这不是一个选项- 我已经审查了类似的问题,但似乎没有其他人遇到完全相同的问题。他们都在使用 JavaScript 而不是 TypeScript,或者他们只是遇到了模板未呈现的问题,并且似乎没有遇到显示模板路径的奇怪问题。
回顾
所以你可以看到我不知所措。使用 typescript 和 webpack 在 angularjs 组件上使用 templateUrl 的正确方法是什么?
解决方案
推荐阅读
- c# - 从已知索引中获取字符串,直到找到 \r\n
- r - 比较矩阵的行并删除项目
- php - 是否可以将成功的登录 cookie 转储到站点并绕过会话?
- java - 如果语句中的 SonarQube Java 'NullPointerException 可能会被抛出'
- asp.net-core - ASP.NET Core SignalR websocket 连接限制
- javascript - 防止空字符串成为数组的一部分
- c# - C# 将共享项目中的类与许多项目集成
- php - 使用 PHP 合并 JSON 数组值
- spring - NoSuchMethodException:org.springframework.boot.autoconfigure.http.HttpMessageConverters
- java - 如何在java上使用/实现滚动条