尝试角度ng路由时出错

Error while trying angular ng route

本文关键字:路由 出错 ng      更新时间:2023-09-26

我尝试使用角度路线(初学者)。

错误 : Uncaught Error: [$injector:modulerr]

我的代码 : 脚本

var indexapp = angular.module('indexApp',[]);
    indexapp.config(function($roteProvider){
      $routeProvider
      .when('/hello' , {
        templateUrl:'app/views/explore.html'
      })
    });

.HTML:只是我添加了<div ng-view></divh>

路由不起作用+顶部的错误

作为文档说你必须在HTML中添加角度路由脚本<script src="angular-route.js">。然后将ngRoute注入到应用。

var indexapp = angular.module('indexApp',['ngRoute']);
indexapp.config(['$routeProvider'], function($routeProvider){
      $routeProvider
      .when('/hello' , {
        templateUrl:'app/views/explore.html'
      })
    });

而且您在<div ng-view></div>中出错

在注册模块时添加 ngRoute 依赖项,

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