Click here to Skip to main content
15,909,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
}

});
Posted
Updated 28-Feb-17 17:58pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900