我需要将$route
变量注入下面的工厂,以便获取GET
请求刷新。我将如何将它注入下面的工厂?角度注入到工厂的多个依赖项
.factory('posts', ['$http', function($http){
//other factory functions
o.factorySubmit = function() {
$http.get('http://localhost:8080/clients').then(function(){
$route.refresh();
});
};
return o;
}])
你一样为$ HTTP完成。请注意,您正在维护序列。当他们被映射。 – ram1993
只要我添加'['$ http','$ route',函数($ http,$ route){'应用程序停止工作 – HoosierCoder
确保已添加'ngRoute'作为依赖项到您的模块。例如,angular.module('yourModule',['ngRoute']) – ram1993