I have this self invoking function for an AngularJS webpage. As you can see, I have this getData () function, whose task is to make an ajax call to get some data when the page loads, and also in accordance with the interaction of users with the page.
<script type="text/javascript">
getData = function (reqData) {
alert(reqData);
};
(function () {
getData = function (reqData) {
alert(reqData);
};
var getData = function (reqData) {
alert(reqData);
};
PatientCategoryController = function ($http, $scope, uiGridConstants) {
getData = function (reqData) {
alert(reqData);
};
var getData = function (reqData) {
alert(reqData);
};
$scope.getData = function (reqData) {
alert(reqData);
};
angular.element(document).ready(getData('someDataToPass'));
}
PatientCategoryController.$inject = ['$http', '$scope', 'uiGridConstants'];
angular.module('demoApp', ['ui.grid', 'ui.grid.autoResize', 'ui.grid.pagination']);
angular.module('demoApp').controller('PatientCategoryController', PatientCategoryController);
}());
</script>
My question is: how to define this function? Should this be defined on the $ scope object? Or do you need to determine on a par with the controller? Or should I define it completely outside the self invoking function?
Also in similar lines where I have to define a javascript object that will contain the data that may be required to call ajax.
, - javascript , . .
javascript, , , javascript. Asp.Net mvc. javascript . , .