У меня проблема с моим js-файлом, использующим AngularJS: «Uncaught Error: [$ injector: modulerr]» - PullRequest
0 голосов
/ 04 апреля 2019

Я занимаюсь формированием AngularJS, и версия, которую использует парень, - 1.0.8, а я использую 1.7.8 angular и хочу обновить это. Кто-нибудь может мне помочь?

Файл: index.html

<!doctype html>
<html ng-app="pessoas">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Pessoas</title>
</head>

<body>

<div ng-controller="CtrlPessoas">
    <h1>Sistemas de gerenciamento de pessoas</h1>

    <ng-view></ng-view>

</div>

</body>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.min.js"></script>
<script src="pessoas.js"></script>

</html>

Файл: listar.html

<h2>Listagem de Pessoas</h2>

<ul>
    <li ng-repeat="pessoa in pessoas">
        {{pessoa.nome}}, {{pessoa.cidade}}
    </li>
</ul>

Файл: pessoas.js

angular
    .module('pessoas', [])

    .config(function ($routeProvider) {
        $routeProvider
            .when('/', {
                templateUrl: 'listar.html'
        });
    })

    .controller('CtrlPessoas', function ($scope) {
        $scope.pessoas = [
            {nome: "Maria", cidade: "São Paulo"},
            {nome: "Jose", cidade: " Cacem"},
            {nome: "Dave", cidade: "Sintra"},
            {nome: "Juan", cidade: "Mexico"}
        ];
    });

1 Ответ

1 голос
/ 04 апреля 2019

У вас отсутствует модуль ngRoute:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular-route.min.js"></script>  


angular.module('pessoas', ['ngRoute'])
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...