我无法从 Angular dart 中的任何列表元素方法(无效参数(索引):“2”)访问它
I can not access it from any list element method (Invalid argument (index): "2") in Angular dart
@Component(
selector: 'my-app',
template: ''' <div> <button (click)="getItemName(2)"> get</button> </div> ''',
)
class ListComponent { //...
List<Product> listProducts;
void getItemName(int id) {
print(listProducts[id].name); // <- invalid argumant (index) : "2"
}
}
html_dart2js.dart:3558 EXCEPTION: Invalid argument (index): "0"
STACKTRACE: Invalid argument (index): "0"
at Object.wrapException (http://127.0.0.1:8092/main.dart.js:4242:17)
at Interceptor.$index (http://127.0.0.1:8092/main.dart.js:1082:19)
at Object.J.$index$asx (http://127.0.0.1:8092/main.dart.js:102985:43)
at GroupsComponent.add (http://127.0.0.1:8092/main.dart.js:45152:46)
at Object.J.add$ax (http://127.0.0.1:8092/main.dart.js:103054:42)
at ViewGroupsComponent0.dart.ViewGroupsComponent0._handle_click_131_0
哪里出错了谢谢
索引参数必须是整数值,不能是字符串。
@Component(
selector: 'my-app',
template: ''' <div> <button (click)="getItemName(2)"> get</button> </div> ''',
)
class ListComponent { //...
List<Product> listProducts;
void getItemName(int id) {
print(listProducts[id].name); // <- invalid argumant (index) : "2"
}
}
html_dart2js.dart:3558 EXCEPTION: Invalid argument (index): "0" STACKTRACE: Invalid argument (index): "0" at Object.wrapException (http://127.0.0.1:8092/main.dart.js:4242:17) at Interceptor.$index (http://127.0.0.1:8092/main.dart.js:1082:19) at Object.J.$index$asx (http://127.0.0.1:8092/main.dart.js:102985:43) at GroupsComponent.add (http://127.0.0.1:8092/main.dart.js:45152:46) at Object.J.add$ax (http://127.0.0.1:8092/main.dart.js:103054:42) at ViewGroupsComponent0.dart.ViewGroupsComponent0._handle_click_131_0
哪里出错了谢谢
索引参数必须是整数值,不能是字符串。