我试图在承诺解决后才显示路线。在控制器中我得到了我的数据。但继续低于错误,进一步处理停止。不确定我错过了什么。
错误:[$ injector:unpr]未知提供者:loadOrderDataProvider< - loadOrderData
这是我正在做的事情。我正在通过$ routeProvider对象中的方法配置路由。
.when('/customers/openOrder', {
templateUrl: 'views/customers/Order.html',
controller: "orderController",
resolve: {
loadOrderData: function(loadOrderService){
return loadOrderService.loadOrderData();
},
}
})
Following is a simple implementation of the methods exposed by the loadOrderService service and followed by controller code that consume loadOrderData from routeProvider.
angular.module("app.orderModule", ["app.anotherOrderModule"])
.factory("loadOrderService", function($http){
return {
loadOrderData : function () {
var promise = $http({
method: 'GET',
url: 'getOrderData()' })
.success(function(data, status, headers, config) {
return data;
});
return promise;
}
};
})
.controller("orderController", [ '$scope', '$http', 'loadOrderData'
function ( $scope, $http, loadOrderData) {
alert('Loaded in controller ' + loadOrderData.data[0].orderName); // **** I AM GETTING orderName HERE
}
]);
答案 0 :(得分:0)
在你的决心obj之后你有一个伪造的逗号
resolve: {
loadOrderData: function(loadOrderService){
return loadOrderService.loadOrderData();
},//???
}