2017-01-22 9 views
11

मैं विजुअल स्टूडियो पर अपना स्वयं का कोणीय 2/एएसपी.नेट एसपीए बनाने की कोशिश कर रहा हूं। आप सभी फाइलें here पा सकते हैं।कोणीय 2/एएसपी.नेट - "कोई संसाधन लोडर कार्यान्वयन प्रदान नहीं किया गया है। यूआरएल नहीं पढ़ सकता"

मैंने जो करने की कोशिश की वह सरल है: ऐप here सेट अप करने के निर्देशों का पालन करने के बाद, मैंने कुछ बुनियादी रूटिंग करने के प्रयास में अपनी फाइलों में जोड़ना शुरू कर दिया और मैंने कुछ अतिरिक्त फाइलों को हटा दिया। मेरे पास है ClientApp/ऐप्स/app.module.ts बूटस्ट्रैपिंग ClientApp/ऐप्स/घटकों/ऐप्स/ app.component.ts, और केवल मार्ग ClientApp/ऐप्स/घटकों/ऐप्स/test.component.ts है

दुर्भाग्य से, मैं यह त्रुटि आई:

An unhandled exception occurred while processing the request. 

Exception: Call to Node module failed with error: Error: No ResourceLoader implementation has been provided. Can't read the url "app.component.html" 
at Object.get (C:\Users\Student\Source\Workspaces\mvs\Test2\Test2\node_modules\@angular\compiler\bundles\compiler.umd.js:17454:17) 
at DirectiveNormalizer._fetch (C:\Users\Student\Source\Workspaces\mvs\Test2\Test2\node_modules\@angular\compiler\bundles\compiler.umd.js:13455:45) 
at DirectiveNormalizer.normalizeTemplateAsync (C:\Users\Student\Source\Workspaces\mvs\Test2\Test2\node_modules\@angular\compiler\bundles\compiler.umd.js:13498:23) 
at DirectiveNormalizer.normalizeDirective (C:\Users\Student\Source\Workspaces\mvs\Test2\Test2\node_modules\@angular\compiler\bundles\compiler.umd.js:13473:46) 
at RuntimeCompiler._createCompiledTemplate (C:\Users\Student\Source\Workspaces\mvs\Test2\Test2\node_modules\@angular\compiler\bundles\compiler.umd.js:16869:210) 
at C:\Users\Student\Source\Workspaces\mvs\Test2\Test2\node_modules\@angular\compiler\bundles\compiler.umd.js:16807:43 
at Array.forEach (native) 
at C:\Users\Student\Source\Workspaces\mvs\Test2\Test2\node_modules\@angular\compiler\bundles\compiler.umd.js:16805:50 
at Array.forEach (native) 
at RuntimeCompiler._compileComponents (C:\Users\Student\Source\Workspaces\mvs\Test2\Test2\node_modules\@angular\compiler\bundles\compiler.umd.js:16804:45) 

सब कुछ मेरे लिए सही लगता है, लेकिन मैं दोनों कोणीय 2 और ASP.NET के लिए नया हूँ, इसलिए अगर यह एक संकलक मुद्दा है मैं नहीं जानता या मानव त्रुटि। यहां कुछ कोड दिए गए हैं, यदि आपको अधिक जानकारी की आवश्यकता है तो रेपो के लिंक इस प्रश्न के शीर्ष पर हैं।

ClientApp/ऐप्स/app.module.ts

import { NgModule } from '@angular/core'; 
import { RouterModule } from '@angular/router'; 
import { UniversalModule } from 'angular2-universal'; 
import { AppComponent } from './components/app/app.component'; 
import { TestComponent } from './components/app/test.component'; 

@NgModule({ 
    bootstrap: [ AppComponent ], 
    declarations: [ 
     AppComponent, 
     TestComponent 
    ], 
    imports: [ 
     UniversalModule, // Must be first import. This automatically imports BrowserModule, HttpModule, and JsonpModule too. 
     RouterModule.forRoot([ 
      { path: 'test', component: TestComponent }, 
      { path: '', redirectTo: 'test', pathMatch: 'full' }, 
      { path: '**', redirectTo: 'test' } 
     ]) 
    ] 
}) 
export class AppModule { 
} 

ClientApp/ऐप्स/घटकों/ऐप्स/app.component.ts

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

@Component({ 
    selector: 'app', 
    templateUrl: './app.component.html', 
    styleUrls: ['./app.component.css'] 
}) 
export class AppComponent { 
} 

ClientApp/ऐप्स/घटकों /app/test.component.ts

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

@Component({ 
    templateUrl: './test.component.html', 
    styleUrls: ['./test.component.css'] 
}) 

export class TestComponent implements OnInit { 
    testing: String; 

    ngOnInit(): void { 
     this.testing = "This Works"; 
    } 
} 
+0

'app.component.html' मौजूद है? आप इसे कोड में संदर्भित करते हैं, लेकिन क्या आपने इसे बनाया है? –

+0

हां, और यह उसी फ़ोल्डर में है जैसे app.component.ts –

+1

क्या आपको कभी इसका कारण मिला? एक ही मुद्दे w/yeoman उत्पन्न परियोजनाओं में चल रहा है। – ohlando

उत्तर

6

वर्तमान में सार्वभौमिक मॉड्यूल की आवश्यकता है कि टेम्पलेट्स और शैलियों के लिए बाहरी संपत्तियों की आवश्यकता()।

templateUrl: './test.component.html'template: require('./test.component.html') को बदलने का प्रयास करें। इस मुद्दे पर

और styleUrls: ['./test.component.css']styles: [require('./test.component.css')] को

अधिक जानकारी यहां पाया जा सकता है: Unable to load assets without using require()

संदर्भ के लिए, Github पर कोणीय से मुद्दा धागा है: track runtime styleUrls। वे angular2-template-loader का उपयोग करने की सलाह देते हैं।

0

(, एक कमांड लाइन विंडो में webpack --version चलाने) अपने webpack संस्करण की जाँच करें, अगर यह तो webpack 2 (2.2.x) का नवीनतम संस्करण स्थापित और समाधान फ़ोल्डर पर चला 1.XX है, और फिर से कोशिश

0

मैं इसमें भाग गया और मेरे मामले में समस्या कोणीय 2-मंदिर लोडर के अपग्रेड से थी। नया संस्करण "0.6.1" ने इस त्रुटि को प्रकट किया। मैंने पिछले संस्करण "0.6.0" पेश किया और सब ठीक काम किया।

0

मेरे पास एक ही समस्या थी और ऊपर दिए गए समाधानों में से कोई भी मदद नहीं करता था। हालांकि, मैं एक Steve Sanderson YouTube video कि templateUrl में उल्लेख देखा था: (और styleUrls:) बस टेम्पलेट के साथ प्रतिस्थापित किया जा सकता: (और शैलियों:)। तो, मैंने अंधेरे में एक शॉट लिया। मेरे लिए यह निश्चित चीजें और मैं अगली बाधा पर जाने में सक्षम था।

4

मेरे समस्या मैं एक webpack noob हूँ था और एक tsc आदेश जो के रूप में Steve Sanderson प्रति अमल करने की कोशिश की:

causes VS to spew garbage .js files all over your source directories...

ठीक

  1. स्वच्छ ऊपर किसी भी *.js और *.js.map फ़ाइलों
  2. है
  3. सुनिश्चित करें <TypeScriptCompileBlocked>*.csproj
  4. में प्रयास करें unning प्रोजेक्ट को फिर से
0

मेरे मामले में मैं घटक के नाम से हाइफन निकाल कर समस्या हल हो जाती: productlist.component => गलत productlist.component => ठीक

1

इस मुद्दे के साथ angular2-template-loader से होता है SSR और देखते हैं कारणों में से एक जोड़े को क्यों इस मुद्दे को प्रकट होता है:

  • महत्वपूर्ण: अगर angular2-template-loader अप टू डेट है की जाँच करें।

आमतौर पर, सभी मुद्दे @Component से संबंधित हैं।

  • जैसा कि घटक नाम में - का उल्लेख किया जाएगा। (यह तय किया गया है) @Component
  • भीतर
  • टिप्पणियाँ
संबंधित मुद्दे