This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// controller function – calling service | |
$scope.loadOrders = function() { | |
orderService.loadOrder() | |
.then(function(result){ | |
if(result) { | |
//populate $scope property for the view | |
} | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myModule') | |
.service('myAuthSvc', ['$http', '$q', function($http, $q){ | |
var loggedInUserDetails = null; | |
this.getLoggedInUserDetails = function(payload) { | |
var deferred = $q.defer(); | |
if(loggedInUserDetails != null) { deferred.resolve(loggedInUserDetails); } | |
else{ | |
$http.post('<loginURL>', /*payload for login*/) | |
.then(function(result){ | |
loggedInUserDetails = result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor(private mathSvc: MathService) { } | |
subtract() { | |
this.result = this.mathSvc.subtract(this.param1, this.param2); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { Observable } from 'rxjs'; | |
@Injectable() | |
export class MathService { | |
constructor() { } | |
subtract(a: number, b: number): number { |