I want to create a widget using the angularjs custom directive, but got stuck somewhere by inserting $ http service into it.
var app = angular.module('app',[]);
app.directive('users',function($scope,$http){
return {
$http.get('https://jsonplaceholder.typicode.com/users')
.then(function(response) {
$scope.user = response.data;
})
}
})
Any thought how to do this? I know that the code above does not work, but I do not know how to proceed.
source
share