I am trying to call a $http Get service on button click in angular js. But I am not getting the data to show in results... My code snippet is as follows:-
<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