我們有一種獨特的情況,我們使用打字稿,混合ng1和2,但不使用任何模塊加載器。我能夠引導ng 1和ng2,但我不能從降級的角度2組件得到任何響應,我在代碼中放置了一個斷點,並看到代碼運行,但組件沒有顯示任何內容。降級的Angular2組件未呈現在角度內1
我沒有得到任何錯誤,不在編譯階段,也不在運行時。
下面的代碼:
myapp.js - 角1個應用定義,ES2015
(function() {
'use strict';
angular.module('myApp', []);
})();
myapp.ng2.ts - 角2的應用程序的定義,打字稿
namespace MyApp {
let NgModule = ng.core.NgModule;
let BrowserModule = ng.platformBrowser.BrowserModule;
let UpgradeAdapter = ng.upgrade.UpgradeAdapter;
@NgModule({
imports: [BrowserModule]
})
export class MyAppNg2 {}
export const upgradeAdapter = new UpgradeAdapter(MyAppNg2);
$(document).ready(function() {
upgradeAdapter.bootstrap(document.body, ['MyApp'], {strictDi: false});
});
}
fullDetails.component.ts - 角度2 ,打字稿
namespace MyApp.Components.Misc {
let Component = ng.core.Component;
@Component({
selector: 'full-details-header',
template: `This is ng2 component`
})
export class FullDetailsHeaderComponent {
}
}
bootstrap.js - angular1,ES2015
angular.module('myApp').component('fullDetailsHeader', MyApp.upgradeAdapter.downgradeNg2Component(MyApp.Components.Misc.FullDetailsHeaderComponent));
你有沒有發現任何解決方案? –