Próbuję zrobić, aby prosty komponent Angular 2 działał wewnątrz aplikacji kątowej 1. Przechodziłem przez this official guide. mam do czynienia jakiś problem z wtryskiem:Angular2 Component w Angular1 App
Unknown provider: $$angularInjectorProvider <- $$angularInjector
Ślad stosu czyni żadnego sensu, ale jest oczywiste, że błąd jest podniesiona gdzieś głęboko w sobie kątowa :)
Struktura mojego obecnego app wygląda następująco:
ng1.module.ts (punkt wejścia):
'use strict';
import { downgradeComponent } from '@angular/upgrade/static';
const angular = require('./lib/angular-wrapper');
const app = angular.module('application', []);
import { AppComponent } from './components/app/app.component.ts';
import { Ng2Module } from './ng2.module.ts';
app.directive(
'app',
downgradeComponent({component: AppComponent}) as angular.IDirectiveFactory
);
angular.bootstrap(document.body, ['application']);
ng2.module.ts:
import 'reflect-metadata';
import '@angular/core';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';
import { AppComponent } from './components/app/app.component.ts';
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
entryComponents: [ AppComponent ]
})
export class Ng2Module {
ngDoBootstrap() {}
}
I app.component.ts:
import 'reflect-metadata';
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: "<h1>HELLO WORLD!</h1>"
})
export class AppComponent {}
wyjściowa dla każdego pomysłu na: co może spowodować, że opisany wyżej błąd?
Hej, mam ten sam problem z moją aplikacją Angular 1.2. Czy miałeś jakieś szczęście, żeby to zrozumieć? –
@MaxPaymar to było na mojej poprzedniej pracy, niestety - nie. Nie rozwiązałem tego.O ile jedna z odpowiedzi ci pomoże - daj mi znać, przyjmuję to. – Lazyexpert