gpt4 book ai didi

javascript - MEAN.JS View 不显示链接是否在新选项卡/窗口中打开

转载 作者:行者123 更新时间:2023-12-03 04:48:28 25 4
gpt4 key购买 nike

框架: MEAN.JS v.0.4.2

我使用 YO 生成器创建了新的“订单”模块。 orders.listorders.view 都可以正常工作。我可以直接使用 url DOMAIN/orders 浏览 orders.list 状态,但我无法浏览 orders .view 状态直接使用 url,例如 DOMAIN/orders/id123。没有错误,但页面是空的。这是我的路线配置文件:

    (function () {
'use strict';

angular
.module('orders')
.config(routeConfig);

routeConfig.$inject = ['$stateProvider'];

function routeConfig($stateProvider) {
$stateProvider
.state('orders', {
abstract: true,
url: '/orders',
template: '<ui-view/>'
})
.state('orders.list', {
url: '',
templateUrl: 'modules/orders/client/views/list-orders.client.view.html',
controller: 'OrdersListController',
controllerAs: 'vm',
resolve: {
orderResolve: getOrders
},
data: {
pageTitle: 'Orders List'
}
})
.state('orders.create', {
url: '/create',
templateUrl: 'modules/orders/client/views/form-order.client.view.html',
controller: 'OrdersController',
controllerAs: 'vm',
resolve: {
orderResolve: newOrder
},
data: {
pageTitle: 'Orders Create'
}
})
.state('orders.edit', {
url: '/:orderId/edit',
templateUrl: 'modules/orders/client/views/form-order.client.view.html',
controller: 'OrdersController',
controllerAs: 'vm',
resolve: {
orderResolve: getOrder
},
data: {
pageTitle: 'Edit Order {{ orderResolve.name }}'
}
})
.state('orders.view', {
url: '/:orderId',
templateUrl: 'modules/orders/client/views/view-order.client.view.html',
controller: 'OrdersController',
controllerAs: 'vm',
resolve: {
orderResolve: getOrder
},
data: {
pageTitle: 'Order Details {{ orderResolve.name }}'
}
});
}

getOrder.$inject = ['$stateParams', 'OrdersService'];
function getOrder($stateParams, OrdersService) {
return OrdersService.get({orderId: $stateParams.orderId}).$promise;
}

newOrder.$inject = ['OrdersService'];
function newOrder(OrdersService) {
return new OrdersService();
}
}());

最佳答案

请在错误日志中查找错误。我发现 View 文件丢失错误。在模板 url 开头添加斜杠可以解决此问题。例如:

templateUrl: '/modules/orders/client/views/...',

关于javascript - MEAN.JS View 不显示链接是否在新选项卡/窗口中打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42763623/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com