When trying to call the submit()
function as soon as the page loads, I keep encountering a submit()
method not found error. The positioning of ng-controller
and onload
is confusing to me.
If there is an alternate method in Angular to achieve this, please provide some guidance.
PS: This is a snippet of code with all variables defined.
<body ng-controller="DashboardDisplay" onload="submit()">
<div class="container-fluid" >
{{scope.arr}}
</div>
</body>
<script>
var myApp = angular.module('myApp',[]);
myApp.controller('DashboardDisplay', ['$scope','$http',function($scope,$http) {
$scope.submit = function(){
var jsonOb = {"A":"B"};
$http.post(URL,jsonOb).
success(function(response) {
console.log('got it' + response);
$scope.arr=response;
}).
error(function(data, status, headers, config) {
console.log('nufin' + status);
});
}
}]);