2017-03-07 2 views
0

Error: XHR error (404) loading https://run.plnkr.co/aT9KvIPBnvAmjN8u/models/homeWarum kann meine Angular2 App mein Modell nicht finden?

Plnkr Link: https://plnkr.co/edit/gwa3NWArtWK0wjf2jr2h?p=preview

habe ich models/home.ts

enter image description here

Welche enthält:

:

export function homeData() { 
    return [ 
    { id: 0, 
     title: '2017 Oscars', 
     graphic: 'https://wikitags.com/images/OscarsBanner.png', 
     categorycards: [ 
     { 
      type: 'image', 
      graphic: 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Ryan_Gosling_2_Cannes_2011_%28cropped%29.jpg/1024px-Ryan_Gosling_2_Cannes_2011_%28cropped%29.jpg?width=440', 
      title: '2017 Oscar Nominee for Best Actor', 
      listings: ['Rayn Gosling', 'Denzel Washington', 'Andrew Garfield', 'Casey Affleck', 'Viggo Mortensen'] 
     }, 
     { 
      type: 'image', 
      graphic: 'https://commons.wikimedia.org/wiki/Special:FilePath/Meryl_Streep_February_2016.jpg?width=440', 
      title: '2017 Oscar Nominee for Best Actress', 
      listings: ['Meryl Streep', 'Emma Stone', 'Natalie Portman', 'Ruth Negga'] 
     }, 
     { 
      type: 'image', 
      graphic: 'https://commons.wikimedia.org/wiki/Special:FilePath/Dev_Patel_(29870651654).jpg?width=440', 
      title: '2017 Oscar Nominee for Best Supporting Actor', 
      listings: ['Dev Patel', 'Jeff Bridges', 'Michael Shannon', 'Lucas Hedges', 'Mahershala Ali'] 
     }, 
     { 
      type: 'image', 
      graphic: 'https://commons.wikimedia.org/wiki/Special:FilePath/Michelle_Williams_by_Gage_Skidmore.jpg?width=440', 
      title: '2017 Oscar Nominee for Best Supporting Actress', 
      listings: ['Michelle Williams', 'Nicole Kidman', 'Viola Davis', 'Octavia Spencer'] 
     } 
     ] 
    } 
    ]; 
} 

Da ist in meinem categoryService.ts ich es wie so importierenmuss

import {homeData} from './models/home'; 

den gesamten Code sein unter:

Doch es kann nicht

enter image description here

Antwort

2

zum src Ordner

und tun dies Bewegen Sie models Ordner gefunden Der Ordner src, weil Sie in Ihrer config.js Datei System.js sagen, dass Ihre App in deristOrdner:

//config.js 
map: { 
    app: "./src" 
    }, 
Verwandte Themen