错误:找不到要加载的主电源插座 [英] Error : Cannot find primary outlet to load

查看:63
本文介绍了错误:找不到要加载的主电源插座的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我尝试了所有在网上找到的内容,但仍无济于事.

So i tried about everything i found online and nothing worked yet.

因此,我遵循了有关路由的有关角度的文档: https://angular.io/docs/ts/latest/guide/router.html

So i followed the doc on angular about routing : https://angular.io/docs/ts/latest/guide/router.html

这是我的login.component.ts

Here is my login.component.ts

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-login',
  template: './login.component.html',
  styleUrls: ['./login.component.css'],
})
export class LoginComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }
}

和我的login.component.html

and my login.component.html

<p>Test login</p>
<router-outlet></router-outlet>

错误:错误:找不到要加载"LoginComponent"的主要插座在getOutlet

error: Error: Cannot find primary outlet to load 'LoginComponent' at getOutlet

所以我有点迷失在这里.我尝试使用:"template:(HTML HERE)"代替templateUrl,同样的事情...

So i'm kind of lost here. I tried using: "template: (HTML HERE)" instead of templateUrl, same thing...

谢谢!

顺便说一句,因为ROUTER_DIRECTIVES已被弃用,所以它不是重复的.

By the way, it's not duplicate since ROUTER_DIRECTIVES have been deprecated.

推荐答案

< router-outlet></router-outlet> rootcomponent appcomponent .

<router-outlet></router-outlet> needs to be placed inside of rootcomponent or appcomponent.

在这里,不确定,但是如果您不希望通过 router 加载 loginComponent 错误的.

Here, not sure but looks like you want to load loginComponent through router if I'm not wrong.

因此,在根或应用程序组件中放置/添加 router-outlet .

(注意:,如果不是您的,则从 LoginComponent 删除 root/app组件 )

So place/add router-outlet in your root or app component.

(NOTE: And remove from LoginComponent if it is not your root/app component)

这篇关于错误:找不到要加载的主电源插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆