でAngular 1.xで投稿リクエストを送信する投稿リクエストURLは、次の形式で更新する必要があります。ファクトリー
https://www.example.com/api/one-push?type=json&query=push&title=____&url=____&tag=___
<form ng-submit="submitUrl()">
<input type="text" class="form-control block" ng-model="url.title" placeholder="title">
<input type="text" class="form-control block" ng-model="url.urlString" placeholder="url">
<input type="text" class="form-control block" ng-model="url.tag" placeholder="tag">
<button>Add</button>
</form>
var app = angular.module('app', [])
.controller('searchController', ['$scope', '$http','searchService', function($scope, $http,searchService) {
$scope.submitUrl = function() {
$scope.url = {};
searchService.updateUrl($scope.url).success(function(data) {
$scope.url = data;
})
}
}]);
app.factory('searchService',function($http) {
var url = " https://www.example.com/api/one-push?";
var Info = {};
Info.updateUrl = function(url) {
return $http.post(url, {
type: "json",
url: url.title,
urlString: url.urlString,
tag: url.tag
});
}
return Info;
});
答えてくれてありがとう。別の補正が_dataにURLを置き換え、それが働いたのparams:{ タイプ: "JSON"、 URL:_data.urlString、 クエリ: 'プッシュ'、 タイトル:_data.title、 タグ:_data.tag を} – rebello