{"id":930,"date":"2023-05-21T03:44:00","date_gmt":"2023-05-21T03:44:00","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=930"},"modified":"2023-05-21T03:44:00","modified_gmt":"2023-05-21T03:44:00","slug":"what-is-service-method","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/21\/what-is-service-method\/","title":{"rendered":"What is service method?"},"content":{"rendered":"\n<p>Service method in AngularJS helps you to define service and method to it. In the following example, we have injected a simple addition service, which adds two numbers.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;! DOCTYPE html>\n&lt;html>\n&lt;head>\n    &lt;meta charset=\"UTF-8\">\n    &lt;title>Event Registration&lt;\/title>\n&lt;\/head>\n&lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.6.4\/angular.min.js\">&lt;\/script>\n&lt;body>\n&lt;h3> IT Notes&lt;\/h3>\n&lt;div ng-app = \"mainApp\" ng-controller = \"DemoController\">\n    &lt;p>Result: {{result}}&lt;\/p>\n&lt;\/div>\n&lt;script>\n    var mainApp = angular.module(\"mainApp\", []);\n    mainApp.service('AdditionService', function(){\n        this.ADDITION = function(a,b) {\n            return a+b;\n        }\n    });\n\n    mainApp.controller('DemoController', function($scope, AdditionService) {\n\n            $scope.result = AdditionService.ADDITION(5,6);\n    });\n&lt;\/script>\n&lt;\/body>\n&lt;\/html><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Service method in AngularJS helps you to define service and method to it. In the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[25],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/930"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=930"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/930\/revisions"}],"predecessor-version":[{"id":931,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/930\/revisions\/931"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}