简体   繁体   中英

cannot load module in angular js

I have simple problem with angularjs

Services.js

'use strict'

var restData = angular.module('ccapp.services', ['ngResource']);

restData.factory('Testcust', function ($resorce) {
    return $resorce('http://localhost:8080/CallCenterRest/webresources/testcust',{},{
       query:{method:'GET', isArray:true} 
    });
});

app.js

var app = angular.module('ccapp', [
    'ngRoute',
    'ccapp.services']);
app.config(function ($routeProvider) {
    $routeProvider
        .when('/viat',
            {
                controller: 'viatctrl',
                templateUrl: 'pages/viat.html'
            })

        .otherwise({ redirectTo: 'index.html' });
});

problem is

Uncaught Error: [$injector:modulerr] Failed to instantiate module ccapp due to: Error: [$injector:modulerr] Failed to instantiate module ccapp.services due to: Error: [$injector:nomod] Module 'ccapp.services' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

somebody can help :)

Check the index.html file to ensure that Services.js is included by a script tag like so <script src="whatever-your-path-is/Services.js"></script> .

If your project was set up such that a grunt or gulp task compiles all javascript files into one file (eg, my-app.js ) to be included in index.html by a script tag, then you need to make sure that this Service.js file is on the path to be processed by the grunt or gulp task.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM