问题描述
嗨CP用户,
我使用本地托管的WCF REST服务,该服务与VS2013和Cordova一起正常工作,并在运行涟漪时突然收到错误。
要使用ANGULARJS工厂设计模式来调用服务..
现在抛出此错误..
和详细信息在这里
选项http:// localhost:4400 / ripple / xhr_proxy?tinyhippos_apikey = ABC& tinyhippos_rur ... Serv.svc / userlogin%3FId%3D352373057521820%26UserName%3Dsrk%26Password%3Ds net :: ERR_CONNECTION_REFUSEDripple.js:50 ripple.define。 object。(匿名函数)angular.js:9814(匿名函数)angular.js:9615 sendReqangular.js:9331 $ get.serverRequestangular.js:13170 processQueueangular.js:13186(匿名函数)angular.js:14383 $ get。范围。$ evalangular.js:14199 $ get.Scope。$ digestangular.js:14488 $ get.Scope。$ applyangular.js:22954(匿名函数)jq uery-2.1.3.js:4430 jQuery.event.dispatchjquery-2.1.3.js:4116 jQuery.event.add.elemData.handle
这里是我的工厂代码..
' use strict';
var app = angular.module(' 应用跨度>);
app.factory(' authorize',函数($ http){
return {
validateUser:功能(凭证){
// return $ http.get(' http:// localhost:1097 / TestServ.svc / userlogin?Id ='+ credential.id +'& UserName ='+ credential.username +'& Password ='+ credential.password +'');
return $ http.get(' http:// localhost:1097 / TestServ.svc / userlogin?Id = 12345& UserName = srk& Password = s');
}
};
});
AND CONTROLLER代码在这里
app.controller(' LoginCtrl', function ($ scope,$ location,$ window,authorize){
$ scope.username = ' ';
$ scope.password = ' ';
$ scope.id = ' 123456';
$ scope.login = function (){
var username = $ scope.username;
var password = $ scope.password;
var id = ' 123456'跨度>;
var credential = {};
credential.username = username;
credential.password =密码;
credential.id = id;
if (username == ' ' ||密码== ' '){
alert( ' 输入用户名和密码......');
}
else {
var promiseGet = authorize.validateUser(凭证);
promiseGet.then( function (pl){
var log = pl.data;
angular.forEach(log, function (value,key){
// this.push(key +':'+ value);
console .log(' valuesGot-' + key + ' :' + value);
});
$ location.path( ' / dashboard');
},
function (errorPl){
alert(' 加载失败员工..' + errorPl);
}
);
}
};
});
Hi CP users,
I m using the locally hosted WCF REST service which was working fine with VS2013 and Cordova and suddenly getting the error when running ripple .
To call the service.. i m using ANGULARJS factory design pattern .
now throwing this error ..
and Detail is here
OPTIONS http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rur…Serv.svc/userlogin%3FId%3D352373057521820%26UserName%3Dsrk%26Password%3Ds net::ERR_CONNECTION_REFUSEDripple.js:50 ripple.define.object.(anonymous function)angular.js:9814 (anonymous function)angular.js:9615 sendReqangular.js:9331 $get.serverRequestangular.js:13170 processQueueangular.js:13186 (anonymous function)angular.js:14383 $get.Scope.$evalangular.js:14199 $get.Scope.$digestangular.js:14488 $get.Scope.$applyangular.js:22954 (anonymous function)jquery-2.1.3.js:4430 jQuery.event.dispatchjquery-2.1.3.js:4116 jQuery.event.add.elemData.handle
And Here is mine factory code..
'use strict'; var app = angular.module('app'); app.factory('authorize', function ($http) { return { validateUser: function (credential) { //return $http.get('http://localhost:1097/TestServ.svc/userlogin?Id=' + credential.id+ '&UserName=' + credential.username + '&Password=' + credential.password + ''); return $http.get('http://localhost:1097/TestServ.svc/userlogin?Id=12345&UserName=srk&Password=s'); } }; });
AND CONTROLLER Code is here
app.controller('LoginCtrl', function ($scope, $location, $window, authorize) { $scope.username = ''; $scope.password = ''; $scope.id = '123456'; $scope.login = function () { var username = $scope.username; var password = $scope.password; var id= '123456'; var credential = {}; credential.username = username; credential.password = password; credential.id= id; if (username == '' || password == '') { alert('Enter username and password...'); } else { var promiseGet = authorize.validateUser(credential); promiseGet.then(function(pl) { var log = pl.data; angular.forEach(log, function (value, key) { // this.push(key + ': ' + value); console.log('valuesGot- ' + key + ': ' + value); }); $location.path('/dashboard'); }, function (errorPl) { alert('failure loading Employee ..' + errorPl); } ); } }; });
这篇关于如何解决这个问题..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!