Use ngResource to query database in AngularJS

53 views Asked by At

I'm trying to use in my app "module ngResource", but i always get this error :

Error: [$injector:modulerr] http://errors.angularjs.org/1.6.3/$injector/modulerr?p0=eliewearApp&p1=%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.6.3%2F%24injector%2Fmodulerr%3Fp0%3DngResource%26p1%3D%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.6.3%252F%2524injector%252Fnomod%253Fp0%253DngResource%250Ahttp%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A6%253A430%250Ahttp%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A26%253A271%250Ab%2540http%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A25%253A300%250Ahttp%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A42%253A119%250Ap%2540http%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A7%253A499%250Ag%2540http%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A41%253A477%250Ahttp%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A42%253A150%250Ap%2540http%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A7%253A499%250Ag%2540http%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A41%253A477%250Aeb%2540http%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A46%253A45%250Ac%2540http%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A21%253A375%250Aue%2540http%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A20%253A380%250Ahttp%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fangular%252Fangular.min.js%253A332%253A119%250Aj%2540http%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fjquery%252Fdist%252Fjquery.min.js%253A2%253A29953%250Ahttp%253A%252F%252Flocalhost%253A3000%252Fbower_components%252Fjquery%252Fdist%252Fjquery.min.js%253A2%253A30263%0Ahttp%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A6%3A430%0Ahttp%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A42%3A409%0Ap%40http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A7%3A499%0Ag%40http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A41%3A477%0Ahttp%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A42%3A150%0Ap%40http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A7%3A499%0Ag%40http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A41%3A477%0Aeb%40http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A46%3A45%0Ac%40http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A21%3A375%0Aue%40http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A20%3A380%0Ahttp%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fangular%2Fangular.min.js%3A332%3A119%0Aj%40http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fjquery%2Fdist%2Fjquery.min.js%3A2%3A29953%0Ahttp%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fjquery%2Fdist%2Fjquery.min.js%3A2%3A30263
(fonction anonyme) (jquery.min.js:2:31643)

This is where I inject ngResource:

angular.module('eliewearApp' ['ui.router','ngSanitize','duScroll','gettext','ngCookies','ngResource'])

This is where I used resource:

'use strict';

angular.module('eliewearApp')
   .constant("baseURL","*****")

   /**
   *** This service renders add data use for school's web view 
   */
   .factory('cursus',['$resource', 'baseURL', function($resource,baseURL){

    var myCursus={};


    //returns my school curriculum
    myCursus.getCursus = function(){
        return $resource(baseURL+"cursusSchool",null, null);
    };

    return myCursus;

   }])

And in my index.html, i include the link to angular-resource :

<script scr="../bower_components/angular-resource/angular-resource.min.js"></script>

I use AngularJS 1.6.3

0

There are 0 answers