私は角度のjsのボタンクリックで$ http Getサービスを呼び出そうとしています。しかし、私は次のように私のコードスニペットがある...結果に表示するデータを取得していない午前: -http getサービスを呼び出し、ボタンクリック時のangularjsのdivでその応答を表示する方法は?
<button ng-controller="myCtrl6" ng-click="search()">Click</button>
<p ng-controller="myCtrl6">
{{results}}
{{fail}}
</p>
var app = angular.module("myApp", []);
app.controller('myCtrl6', ['$scope', '$http', function ($scope, $http) {
$scope.results = "";
$scope.fail = "f";
$scope.search = function() {
$http.get('welcome.html', {}, function(response) {
$scope.results = response.data;
}, function (failure) {
console.log("failed :(", failure);
});
}
}]);
のwelcome.html
Hello World
を書くのか? – L4reds
これをチェックしてくださいhttps://stackoverflow.com/questions/41169385/http-get-success-is-not-a-function –
then()関数が必要です! –