Support Angular 16's new component route data binding
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 45/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- angular, typescript
研究方向
從 NativeScriptRouterModule.forRoot 開始,檢查其路由設定如何處理 bindToComponentInputs 和 outlet 警告。使用路由資料和一個 @Input 重現 Angular 16 範例;當警告消失且元件 input 在初始化期間包含路由資料時,工作就完成了。
由索引模型根據 Issue 內容生成。
描述
Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
- NativeScript-Angular: 16
- Angular: 16
Describe the bug
In angular 16, you can add bindToComponentInputs to Angular's Router Module imports: [NativeScriptRouterModule.forRoot(routes, { bindToComponentInputs: true })], to automatically populate @Input() properties in the component. Doing so in Nativescript—Angular warns the dev
CONSOLE WARN: 'withComponentInputBinding' feature is enabled but this application is using an outlet that may not support binding to component inputs.
To Reproduce
Add bindToComponentInputs: true to the forRoot function's 2nd parameter config object.
import { NgModule } from '@angular/core';
@NgModule({
imports: [NativeScriptRouterModule.forRoot(routes, { bindToComponentInputs: true })],
})
export class AppRoutingModule {}
export const testPageRoute: Route = {
path: ':page',
component: TestComponent ,
data: {'test': 'test-text'}
};
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'test-component',
templateUrl: './test-component.html',
})
export class TestComponent implements OnInit {
@Input() public test;
public ngOnInit(): void {
console.log(this.test); // should populate with 'test-text'
}
}
Expected behavior
this.test should populate with the data from the route without having to query in the OnInit lifecycle.
Additional context
https://blog.angular.io/angular-v16-is-here-4d7a28ec680d#398f
- 主要語言
- TypeScript
- 星號
- 55
- 分支
- 13
- 平均合併
- 16 分鐘
- 30 天內合併 PR
- 1
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
NativeScript/angular 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 45/100
NativeScript/angular#170 · 1 則留言 ·
-
難度 5/5 一週以上 新手友好度 35/100
NativeScript/angular#164 ·
-
難度 2/5 1-3 小時 新手友好度 45/100
NativeScript/angular#163 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 38/100
NativeScript/angular#158 · 1 個 reaction ·
-
難度 2/5 1-3 小時 新手友好度 35/100
NativeScript/angular#155 ·
查看 NativeScript/angular 的全部 Issue
相似的 Issue
-
Type/Bug
難度 2/5 1-3 小時 新手友好度 78/100
OpenNSW/nsw-srilanka#497 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
0xMiden/bridge-portal#132 ·
-
react-doctor severity:warning tech-debt
難度 1/5 1 小時以內 新手友好度 88/100
digidem/comapeo-cloud-app#403 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 78/100