【问题标题】:Update to angular component router from original angular router gives the errors:从原始角度路由器更新到角度组件路由器会产生错误:
【发布时间】:2017-03-25 16:59:11
【问题描述】:

在此处查看代码:http://plnkr.co/edit/xIRiq10PSYRsvNE0YWx7?p=preview

我收到以下 2 个错误。

  1. 路由必须提供路径或正则表达式属性
  2. [$compile:ctreq] http://errors.angularjs.org/1.5.3/$compile/ctreq?p0=ngOutlet&p1=ngOutlet

index.html

<!DOCTYPE html>
<html ng-app="favMoviesList">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js</script>
<script src="https://unpkg.com/@angular/router@0.2.0/angular1/angular_1_router.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" />
<script src="module.js"></script>
<script src="movies-list-component.js"></script>
<script src="movie-rating-component.js"></script>
<script src="movie-app-component.js"></script>
</head>

<body>
<movie-app></movie-app>
</body>

</html>

module.js

(function(){
var module = angular.module("favMoviesList",["ngComponentRouter"]);

module.value("$routerRootComponent","movieApp");

module.component("appAbout",{
template:"This is about page"
});
}());

movie-app-component.js

(function(){
var module = angular.module("favMoviesList");

module.component("movieApp",{
templateUrl:"movie-app-component.html",
$routeConfig:[
  { path:"/list",component:"movieList",name:"List"},
  { path:"/about",component:"appAbout",name:"About"},
  { paht:"/**", redirectTo:["List"] }]
});
}());

【问题讨论】:

    标签: javascript angularjs angular-components angularjs-1.5 angular-component-router


    【解决方案1】:

    你打错了:paht 应该是path

    第二个错误是因为找不到指令“ngOutlet”所需的控制器“ngOutlet”。

    【讨论】:

    • 感谢您的回复。关于第二个错误,据我了解,ng-outlet 就像 ng-view。所以,我早先在 movie-app-component.html 中添加了它。我不明白。你可以说得更详细点吗。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2018-08-04
    • 2018-10-12
    • 2018-05-17
    • 1970-01-01
    • 2018-02-06
    • 2020-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多