這是不能夠編譯plunkr有點困難,但是你能告訴我,如果這個工程:
factory.js:
routingRulesHelper.factory('ruleSetQueryWrapper', ['$q','RuleSets',
function($q, RuleSets) {
var formatResults = function (ruleSet) {
var aRuleSchedule = {};
//format the payload to correct data ...........
return aRuleSchedule;
};
return {
getRuleSetById: function(ruleSetId){
var deferred = $q.defer();
var ruleset = RuleSets.query({ruleSetId: ruleSetId}, function(ruleSet) {
deferred.resolve(formatResults(ruleSet));
}, function(response) {
//404 or bad
if(response.status === 404) {
console.log("HTTP Error", response.status);
}
deferred.reject();
});
return deferred.promise;
}
}}]);
controller.js:
routingRulesControllers.controller('RulesDisplayCtrl', ['$scope', '$location', '$routeParams', 'RuleSets', 'ruleSetQueryWrapper',
function($scope, $location, $routeParams, RuleSets, ruleSetQueryWrapper) {
$scope.formattedResults = null;
if($routeParams.ruleSetId) {
ruleSetQueryWrapper.getRuleSetById($routeParams.ruleSetId).then(function(results) {
$scope.formattedResults = results;
});
}
}]);
如果重擊者不起作用,那麼我們如何才能弄清楚如果你的代碼存在問題或者只是在重擊者身上? –
而不是使用一個因素你試過一個服務?來自:routingRulesServices.factory('RuleSets'到:routingRulesServices.service('RuleSets' –
嗨安東尼朱,我明白這是很難與一個代碼示例,不編譯,但我相信我的問題是一個根本的理解不夠,所以我確信有人可以協助,Wawy能夠:) –