I am looking to develop my own custom plugin or module for angular 1.5, similar to the $http
service.
For example, let's create a file named "angular-own-plugin.js":
angular.module('ownPlugin', function() {
$scope.functionA = function () {return 1;};
$scope.functionB = function () {return 2;};
$scope.functionC = function () {return 3;};
$scope.functionX = function (n) {return n * $scope.functionA();};
})
Now, let's integrate the $ownPlugin
:
.controller('MyCtrl', function ($http, $ownPlugin){
$scope.number = $ownPlugin.functionX(10);
})
I'm unsure about the best approach for creating this plugin. Should I use a factory, service, or another method?
Thank you