2016-04-18 2 views
0

私のイオンアプリのボタンに投稿リクエストを追加しようとしていますが、コードを追加するとアプリが役に立たなくなることがわかりました。一つのものが私のタップのどれにも反応しません。コードを削除すると、再び正常になります。

$scope.powerPrompt = function() { 
    var pwr = alert("Power On"); 
    $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; 
    $http({ 
     method: 'POST', 
     url: 'url', 
     data: "string" 
     headers: {'Content-Type': 'application/x-www-form-urlencoded'} 
    }).success(function(response) { 
     // handle success things 
    }) 
    .error(function(data, status, headers, config) { 
     // handle error things 
    }) 
}; 

私はVaRのPWRライン、私のアプリの作品の残りの部分を除いてpowerPrompt関数内のすべてを削除した場合:これは私が追加されているすべてのです。これは何の原因ですか?構文の問題がありますか?

答えて

1

あなたが欠落している,dataプロパティ後

$scope.powerPrompt = function() { 
    var pwr = alert("Power On"); 
    $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; 
    $http({ 
     method: 'POST', 
     url: 'url', 
     data: "string", 
     headers: {'Content-Type': 'application/x-www-form-urlencoded'} 
    }).success(function(response) { 
     // handle success things 
    }) 
    .error(function(data, status, headers, config) { 
     // handle error things 
    }) 
}; 
関連する問題