javascript - how to use multipal components in angular2 -


i new in angular2, trying use 2 components in single page gives me 404 error.

this 2 .ts files

app.ts

import {component, view, bootstrap} 'angular2/angular2';  import {events} './event.component';  @component(     {         selector: 'contact'     })     @view({          templateurl: './travel operator/login.html',          directives: [events] })  export class contact { }  bootstrap(contact); 

and event.component.ts

import {component, view, bootstrap} "angular2/angular2";  @component(     {          selector: 'events'     }) @view({         template: '<h1>hello world</h1>' })   export class events {      } }  bootstrap(events); 

and trying use on main index.html file like

<html> <body>     <h1>first angular app</h1>      <div id="content">         <contact></contact>     </div>     <div id="events">         <events></events>     </div>  </body> </html> 

but gives

"networkerror: 404 not found - http://localhost:55777/event.component" error

i stuck on there please help

the problem module containing event component isn't correctly loaded. it's rather problem systemjs configuration. perhaps don't put typescript files app or src folder.

from 5 min quickstart (https://angular.io/guide/quickstart):

var map = {   'app': 'app', // 'dist',   (...) }  var packages = {   'app': { main: 'main.js',  defaultextension: 'js' },   (...) }; 

in case, both js files components (resulting typescript transpilation) located in same folder (the app one) import {events} './event.component'; event.component.js file in app folder.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -