/*
* ----- Controller.js
* ----- Required dependencies are injected into the controller’s signature
*/
function MyAccountController($scope, $http, GenericService){
$scope.findAccountInfo = function () {
$scope.removeFetchedData();
$scope.getAccountInfo(); //// Calling Service from this function
console.log($scope.fetchedData);
}
$scope.getAccountInfo = function () {
//ROUTING WITH IN INDEX PAGE
var myModule = angular.module('myModule', [])
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$routeProvider.
when('/videos', {templateUrl: 'myPages/Welcome.html'}).
when('/videos/logout', {templateUrl: 'login.html'}).
. . .
. . . . .
otherwise({redirectTo: '/videos'});
}]);
////---- WRITING SERVICE FACTORY TO CONSUME WEB SERVICE ---- ////
myModule.factory('GenericService', ['$http', function($http) {
var service = {
getAcctInfo: function (acctno) {
alert("Here inside factory method");
console.log("Account No : " + acctno);
var accountInfo = {};
accountInfo.accountno=acctno;
success(function(data, status, headers, config) {
/// some actions taken
}).
error(function(data, status, headers, config) {
//// Some messages logged
});
}
};
return service;
}]);