Module "ui.router" is unavailable

I am new in AngularJS

I get this error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module ui.router due to:
Error: [$injector:nomod] Module 'ui.router' 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.

This is index.html file:

<!doctype html>
<html ng-app="app">
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Untitled</title>
        <link rel="stylesheet" href="css/style.css">
        <link rel="author" href="humans.txt">



    </head>
    <body ng-controller="FirstCtrl">

    <input type="text" ng-model="first.greeting"/>
    <div ng-class="first.greeting">{{first.greeting}}</div>



    <script src="angular.js"></script>
    <script src="app/app.js"></script>
    <script src="js/main.js"></script>
    </body>
</html>

and this is the app.js file:

var app = angular.module("app", ["ui.router"]).controller("FirstCtrl", function FirstCtrl(){
            var first = this;
            first.greeting = "First";
        });

Please help me solve this problem.

+4
source share
4 answers

You do not load the script in ui-router, I do not know if you have locally or using cdn, you just need to add it to your index.html there

for example by adding-

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.min.js"></script>

in your index.html (this is a cdn link)

+9
source
<script src="angular.js"></script>

This is just the basic angular library, you need to either download, download the latest version of angular ui router library, or output it from the CDN

see here for more details: https://github.com/angular-ui/ui-router

0
source

:

angular -ui-router npm

npm install angular-ui-router@0.2.18 --save

script index.html(angular 1.5.0)

<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/angular-ui-router/release/angular-ui-router.js"></script>
0

Can be installed via nuget

PM> Install-Package Angular.UI.UI-Router

0
source

Source: https://habr.com/ru/post/1609358/


All Articles