Я занят приложением Angular2 и испытываю что-то очень странное ... Я создал новый компонент с использованием углового cli называемый Товарно-внедренный Компонент. когда я импортирую компонент в мои app.module.ts и app.routing.ts Я не получаю никаких ошибок сборки, но когда я добавляю путь к GoodsReceived в моем app.routing.ts, я получаю сообщение о том, что GoodsReceivedComponent не часть любого модуля, но он импортируется в мой app.module ... Любая идея, что здесь может быть неправильным?Angular2: Очень странное поведение, ошибка, связанная с компонентом, который не импортирован, хотя он импортирован в app.module
мой код:
товары-received.component.ts:
export class GoodsReceivedComponent implements OnInit {
в app.module.ts:
import { GoodsReceivedComponent } from './Components/goods-received/goods-received.component';
declarations: [
AppComponent,
ProductComponent,
CheckBarcodesComponent,
HomeComponent,
NavigationComponent,
SettingsComponent,
StockTransactionItemComponent,
StockTakeComponent,
spinners.CircleComponent,
LoaderComponent,
ErrorComponent,
GoodsReceivedComponent
],
в приложении. routing.ts:
import { GoodsReceivedComponent } from './components/goods-received/goods-received.component';
const appRoutes : Routes = [
{path: "settings", component: SettingsComponent },
{path: "checkBarcodes", component: CheckBarcodesComponent },
{path: "home", component: HomeComponent},
{path: "", redirectTo: 'home', pathMatch: 'full'},
{path: "stockTake", component: StockTakeComponent}
{path: "goodsReceived", component: GoodsReceivedComponent}
];
моя ошибка:
runtime_compiler.js:215Uncaught Error: Component GoodsReceivedComponent is not part of any NgModule or the module has not been imported into your module.
at RuntimeCompiler._createCompiledHostTemplate (http://localhost:4200/main.bundle.js:38664:19)
at http://localhost:4200/main.bundle.js:38623:37
at Array.forEach (native)
at http://localhost:4200/main.bundle.js:38621:45
at Array.forEach (native)
at RuntimeCompiler._compileComponents (http://localhost:4200/main.bundle.js:38612:43)
at RuntimeCompiler._compileModuleAndComponents (http://localhost:4200/main.bundle.js:38539:37)
at RuntimeCompiler.compileModuleAsync (http://localhost:4200/main.bundle.js:38530:21)
at PlatformRef_._bootstrapModuleWithZone (http://localhost:4200/main.bundle.js:27267:25)
at PlatformRef_.bootstrapModule (http://localhost:4200/main.bundle.js:27249:21)
RuntimeCompiler._createCompiledHostTemplate @ runtime_compiler.js:215
(anonymous) @ runtime_compiler.js:174
(anonymous) @ runtime_compiler.js:172
RuntimeCompiler._compileComponents @ runtime_compiler.js:163
RuntimeCompiler._compileModuleAndComponents @ runtime_compiler.js:90
RuntimeCompiler.compileModuleAsync @ runtime_compiler.js:81
PlatformRef_._bootstrapModuleWithZone @ application_ref.js:328
PlatformRef_.bootstrapModule @ application_ref.js:310
(anonymous) @ main.ts:12
__webpack_require__ @ bootstrap 1f81207…:52
(anonymous) @ zone.js:1428
__webpack_require__ @ bootstrap 1f81207…:52
webpackJsonpCallback @ bootstrap 1f81207…:23
(anonymous) @ main.bundle.js:1
client:38 [WDS] Errors while compiling.
client:80 [default] C:\Users\Deon\Documents\trade-link\barcode-checker\src\app\app.routing.ts:16:1
',' expected.
errors @ client:80
sock.onmessage @ socket.js:37
EventTarget.dispatchEvent @ eventtarget.js:51
(anonymous) @ main.js:274
SockJS._transportMessage @ main.js:272
EventEmitter.emit @ emitter.js:50
WebSocketTransport.ws.onmessage @ websocket.js:35
wrapFn @ zone.js:698
ZoneDelegate.invokeTask @ zone.js:265
Zone.runTask @ zone.js:154
ZoneTask.invoke @ zone.js:335
Вы можете показать полный список приложений.module.ts? Мы даже не видим '@ NgModule' – echonax
. Я предлагаю вам поместить запятую в эту строку: {path:" stockTake ", компонент: StockTakeComponent} – lexigren
В app.module.ts импортируется импортная импорция {GoodsReceivedComponent} из '. /Components/goods-received/goods-received.component '; Компоненты имеют капитал 'c' – JSNinja