简体   繁体   中英

Angular2 Routing error/missing component

Link to full project without modules: https://www.dropbox.com/s/eaesfz4wvixusn5/EbayClone.zip?dl=0

I'm trying to add a webpage that is called "LogInPage" just for testing purposes. After running npm start, I get this error which basically says that I should add a "LogInPage" file to the nodes_modules folder. After I do that, I get another error that says missing "async". I'm not sure if my routing is correct because I have tried importing the "login component" but it says it's missing from nodes_modules.

Screenshot of error while trying to load webpage: enter image description here

App.component.ts code

import {Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {LogInComponent} from 'angular2/LogInPage';

@Component({
 selector: 'LogInPageSelector',
 template: `
 <h1>{{title}}</h1>
 <nav>
 <a [routerLink]="['LogIn']">Log in</a>
</nav>
 <router-outlet></router-outlet>
 `,
 styleUrls: ['app/app.component.css'],
 directives: [ROUTER_DIRECTIVES],

})
@RouteConfig([

 {path: '/LogIn', name: 'LogIn', component: Component, useAsDefault: true},

])
export class AppComponent {
 title = 'Ebay clone';
}

Code for LogInPage.component.ts

import {Component} from 'angular2/core';
import {Router} from 'angular2/router';
@Component({
 selector: 'LogInPageSelector',
 templateUrl: 'app/loginpage.component.html',
 styleUrls: ['app/loginpage.component.css']
})
export class LogInComponent {
 constructor(private LogInService: LogInComponent, private _router: Router) { }
}

loginpage.component.html code:

<html>
 <h1>Hello</h1>
</html>

我想您忘记在主HTML文件中包含“router.dev.js”文件:

<script src="node_modules/angular2/bundles/router.dev.js"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM