- 1 year ago 153
HTML Question

Angular js returning error Unknown provider:

I created a factory dtoResource.js to work with my data as per different form.

I am trying to inject this factory in autoQuoteCtrl in autoQuoteCtrl.js file.

But its giving error

angular.js:13424 Error: [$injector:unpr] Unknown provider: $resourceProvider <- $resource <- dtoResource$injector/unpr?p0=%24resourceProvider%20%3C-%20%24resource%20%3C-NaNtoResource
at Object.getService [as get] (
at getService (
at injectionArgs (
at Object.invoke (
at Object.enforcedReturnValue [as $get] (
at Object.invoke (

My code of controller is as below

(function () {
"use strict";

.controller("autoQuoteCtrl", ["$scope","$http","$state","dtoResource", function($scope,$http, $state,dtoResource) {
$scope.onSubmit = function() {
// add check if valid
//call function from your service, and do something with it
alert('hi, I was invoked on form submit');
method : 'POST',
url : 'api.php',
data : { dtoObj: JSON.stringify(prepareAutoQuoteDTO.postAutoQuoteObj) }, // pass in data as strings
headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload)
.success(function(data) {
if (!data.success) {

} else {
// if successful, bind success message to message
//$scope.message = data.message;

What I am missing here.
Created plunker with complete code.

Answer Source

You need to include the angular-resource script. It's in a different module.

Here's a cdn reference you can use if you want.

<script src=""></script>

And make sure you add it as a dependency to your module:

var app = angular.module("autoQuote",["ui.router", "ngResource"]);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download