自從我將代碼從Angular 2 RC5遷移到2.2.0以來,我遇到了一個令人驚訝的問題。我注入到服務的其他服務一樣,:Angular 2.2.0注入從RC5遷移=>切換注入
constructor(_http:Http,
_cachingServices:CachingServices,
_globalServices:GlobalServices,
_dataServices:DataServices,
_notificationServices:NotificationServices)
這是工作在RC5罰款,但現在,隨着2.2.0版本,注射混合!下面的代碼:
// Constructor
constructor(_http:Http,
_cachingServices:CachingServices,
_globalServices:GlobalServices,
_dataServices:DataServices,
_notificationServices:NotificationServices){
console.debug(this.className + " param globalServices => ",_globalServices);
console.debug(this.className + " param cachingServices => ",_cachingServices);
console.debug(this.className + " param dataServices => ",_dataServices);
console.debug(this.className + " param notificationServices => ",_notificationServices);
}
給我下面的結果:
TranslateServices param globalServices => DataServices {connectionStrings: Object, mode: "dev", magicServices: MagicServices, apiURL: "http://127.0.0.1/api.php", baseURL: "http://localhost:3000"}
TranslateServices param cachingServices => CachingServices {expiration: EventEmitter, cacheduration: 400000}
TranslateServices param dataServices => NotificationServices {notification: EventEmitter, types: Object, notification_one_like_per_day: "notification_one_like_per_day", notification_one_message_per_day: "notification_one_message_per_day", notification_thanks_for_message: "notification_thanks_for_message"…}
TranslateServices param notificationServices => GlobalServices {mode: "dev", apiURL: "http://127.0.0.1/api.php", baseURL: "http://localhost:3000"}
ERROR =>服務引用混合! 我搜索了一段時間沒有任何開始的答案。
謝謝! OMG!
你可以在Plunker中重現嗎?我想這是你的本地設置的一些問題,因爲這通常是正常的。 –
我充滿善意,但這需要我很多時間。如果我能避免那會很好。 :'( – Ivan
+如果我在構造函數中切換聲明,結果是不一樣的 – Ivan