I create TemplateService as factory in I call GetBracket it will call GetBracket From controller. But in GetBracket Function will required $resouce & $http service is undefined in factory. I add ngResource dependancy in my app. And Refrence of
angular.js
,
angular-resource.js
in the html page & defined ng-app and ng-controller directive.
What I have tried:
var app = angular.module('myApp', ['ngResource']);
app.controller('myCtrl', ['$scope', '$http', 'TemplateService', function ($scope, $http, TemplateService) {
$scope.firstName = "";
$scope.lastName = "";
$scope.Click = function () {
TemplateService.GetBracket().then(function (accountList) {
$scope.firstName = accountList;
});
}
}]);
app.factory("TemplateService", function ($http, $resource) {
return {
GetBracket: GetBracket
};
function GetBracket($http, $resource) {
return $resource('/Home/Name', {}).get().$promise();
}
});