[英]Template path instead of it self in AngularJS
我正在使用Angular ui-Router和ui-View在應用程序中為其提供服務。 這是我的路線索引:
function routeConfig($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$stateProvider
.state('app', {
url: '',
template: require('./pages/generic/generic.html'),
data: {
public: true
},
})
.state('app.main', {
url: '/',
template: require('./pages/main/main.html'),
controller: 'MainCtrl',
controllerAs: 'Ctrl'
});
...
而不是模板本身,我看到了它的路徑。 另外,當我使用templateUrl
我Cannot GET /template-file-path
。 為什么會發生? 我正在將webpack與webpack服務器一起使用。 謝謝。
如果您的應用程序的文件結構是
myDemoAppName -> app -> pages -> main -> main.html
並且您的服務器在myDemoAppName
路徑上提供文件
您應該使用templateUrl: '/app/pages/main/main.html'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.