私は、初期化を行うときに約束を使うコントローラでテストを作成するのは難しいです。ここに私のanglejs scirptです。 $ httpBackendを使用して
javascript.jsを
var appModule = angular.module('appModule', []);
appModule.controller('c0001Controller', function($http, $window) {
var user = {};
this.c0001Data = user;
this.submitForm = function() {
if(!angular.isUndefined(this.c0001Data.user_id) && !angular.isUndefined(this.c0001Data.password))
{
var promise = $http.post('C0001Login', user);
promise.success(function(data, status, headers, config) {
if(data.message == 'error'){
alert('Invalid Username/Password');
} else {
$window.location.href = data.url + "#/c0003";
}
});
promise.error(function(data, status, headers, config) {
alert("Invalid Username/Password");
});
}
else {
alert ("Invalid/ Username/password");
}
};
});
約束に基づく初期化コードは表示されません。それはどこにある? – Phil
'submitForm'メソッドをテストするには、' ngMock'モジュールの '$ httpBackend'を使用してください。 – Phil
OH申し訳ありませんが、私は間違った質問を投稿しました。" $ httpのHttpBackendの使い方 "、私の投稿を編集します。 – Brexter