Failed to load module in Angular JS

Akshay Bhat

I have a html file

<!doctype html>
<html lang="en" ng-app="myApp">
<head>
  <meta charset="UTF-8">
  <title>Angular Registration</title>
  <meta name="viewport" content="width=device-width, user-scalable=no">
  <link href='https://fonts.googleapis.com/css?family=Lato:400,100,700,900' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" href="css/style.css">
  <script src="js/lib/angular/angular.min.js"></script>
  <script src="js/lib/angular/angular-route.min.js"></script>
  <script src="js/lib/angular/angular-animate.min.js"></script>
  <script src="js/app.js"></script>
  <script src="js/controllers/registration.js"></script>
</head>
<body>
<header></header>
<div class="page">
  <main class="cf" ng-view>
  {{message}}</main>
</div>
</body>
</html>

Then I have app.js where i implement route providers.

var myApp = angular.module('myApp',['ngRoute']);

myApp.config(['$routeProvider',function($routeProvider){
    $routeProvider.
        when('/login',{
            templateUrl:'views/login.html',
            controller:'RegistrationController'
        }).
        when('/register',{
            templateUrl: 'views/register.html',
            controller: 'RegistrationController'
        }).
        when('/success',{
            templateUrl: 'views/success.html',
            controller: 'SuccessController'
        }).
        otherwise({
            redirectTo:'/login'
        });
}]);

Then I have a registration.js where I implement the controller

myApp.controller('RegistrationController',['$scope',function($scope){
    $scope.message="Welcome to my app";
}]);

this is the view file I am referring to:

<section class="card login">
  <form name="myform"
    novalidate>

    <div class="textintro">
      <h1>Hi there!</h1>
      <p>Log-in to access the awesomeness!</p>
      <p>{{message}}</p>

    </div>

    <fieldset>
      <input type="email" name="email" placeholder="Email">
      <input type="password" name="password" placeholder="Password">
    </fieldset>

    <button type="submit" class="btn">Login</button>
    <p>or <a href="#/register">register</a></p>
  </form>
</section>

The {{message}} is displayed as it is when I run the website !! I checked the console it says failed to load the module, what might be my mistake here or how can I solve this

Cabe Skuriles

Is your controller in the same file as the route config or it is separate file?

If it is in an extra file you have to replace

myApp.controller('RegistrationController',['$scope',function($scope){

with

angular.module('myApp').controller('RegistrationController',['$scope',function($scope){

If it is in the same file, please post the error message here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Failed to Instantiate Module Angular JS

From

Angular 2 unit testing - getting error Failed to load 'ng:///DynamicTestModule/module.ngfactory.js'

From Dev

Failed to load PDF document - Angular JS - BLOB

From Dev

Failed to instantiate module error in Angular js

From Dev

Angular JS : Failed to instantiate module test due to:

From Dev

How to fix: "Failed to load module script ..." Angular 8, Electron 5

From Dev

Electron Failed to load Module

From Dev

Failed to load kafka module

From Dev

Angular 7: ngsw-worker.js failed to load

From Dev

Angular JS, UI-Bootstrap Failed to load template

From Dev

Haskell Failed to load interface for module

From Dev

Webpack build Angular.js - Failed to instantiate module app

From Dev

Angular JS : Uncaught Error: [$injector:modulerr] Failed to instantiate module

From Dev

Failed to load .js resource

From Dev

Failed to load module "canberra-gtk-module"

From Dev

Failing to load an angular module

From Dev

Nuxt Cannot load payload _payload.js TypeError: Failed to resolve module specifier '_payload.js'

From Dev

Angular.JS: Failed to instantiate module routing due to: Error: $injector:nomod Module 'routing' is not available

From Dev

Angular and html - Failed to load resource

From Dev

module build failed in angular router

From Dev

angular module: Failed to instantiate module due to

From Dev

The Module "aspnetcorev2.dll" failed to load

From Dev

Wildfly Failed to Load Module for Oracle Driver

From

Android Firebase DynamiteModule: Failed to load module descriptor

From

Android failed to load JS bundle

From Dev

Failed to load resource in Node JS

From Dev

Gulpfile.js failed to load

From Dev

Lazy load module in angular 8

From Dev

How to wait for Angular module to load?

Related Related

  1. 1

    Failed to Instantiate Module Angular JS

  2. 2

    Angular 2 unit testing - getting error Failed to load 'ng:///DynamicTestModule/module.ngfactory.js'

  3. 3

    Failed to load PDF document - Angular JS - BLOB

  4. 4

    Failed to instantiate module error in Angular js

  5. 5

    Angular JS : Failed to instantiate module test due to:

  6. 6

    How to fix: "Failed to load module script ..." Angular 8, Electron 5

  7. 7

    Electron Failed to load Module

  8. 8

    Failed to load kafka module

  9. 9

    Angular 7: ngsw-worker.js failed to load

  10. 10

    Angular JS, UI-Bootstrap Failed to load template

  11. 11

    Haskell Failed to load interface for module

  12. 12

    Webpack build Angular.js - Failed to instantiate module app

  13. 13

    Angular JS : Uncaught Error: [$injector:modulerr] Failed to instantiate module

  14. 14

    Failed to load .js resource

  15. 15

    Failed to load module "canberra-gtk-module"

  16. 16

    Failing to load an angular module

  17. 17

    Nuxt Cannot load payload _payload.js TypeError: Failed to resolve module specifier '_payload.js'

  18. 18

    Angular.JS: Failed to instantiate module routing due to: Error: $injector:nomod Module 'routing' is not available

  19. 19

    Angular and html - Failed to load resource

  20. 20

    module build failed in angular router

  21. 21

    angular module: Failed to instantiate module due to

  22. 22

    The Module "aspnetcorev2.dll" failed to load

  23. 23

    Wildfly Failed to Load Module for Oracle Driver

  24. 24

    Android Firebase DynamiteModule: Failed to load module descriptor

  25. 25

    Android failed to load JS bundle

  26. 26

    Failed to load resource in Node JS

  27. 27

    Gulpfile.js failed to load

  28. 28

    Lazy load module in angular 8

  29. 29

    How to wait for Angular module to load?

HotTag

Archive