Angular 2/Dart 구성 요소에 사용할 templateUrl을 동적으로 전환하려고합니다.다트를 사용하여 각도 2로 동적 구성 요소를 만드는 방법은 무엇입니까?
내가가는 길은 templateUrl을 배치 할 새 구성 요소를 동적으로 만드는 것임을 알았습니다. TypeScript가있는 Angular 2 ComponentResolver for example this one을 사용하여이를 수행하는 방법에 대한 몇 가지 예가 있지만 그 중 일부를 Dart로 변환하는 데 실패했습니다.
기본적으로 내가 함수에서 새 구성 요소를 통과하지 못할 것 :
createComponentFactory(ComponentResolver resolver,
ComponentMetadata metadata) {
final cmpClass = class DynamicComponent {};
final decoratedCmp = Component(metadata)(cmpClass);
return resolver.resolveComponent(decoratedCmp);
}
이와 다트와 다른 유사한 접근 방식의 문제는 내가 변수에 class DynamicComponent {};
을 설정하거나에서 반환 할 수 없다는 것입니다 이 같은 빌드 오류를받지 않고 기능 : 나는 동적 구성 요소를 만들기위한 본 적이 예제 중 하나를 다음과 같은 경우
[DirectiveProcessor]:
Failed with 5 errors
Error 1: line 37, column 22 of lib/projects/project_component.dart and parts: Expected an identifier
final cmpClass = class DynamicComponent {};
^^^^^
Error 2: line 37, column 22 of lib/projects/project_component.dart and parts: Expected to find ';'
final cmpClass = class DynamicComponent {};
^^^^^
Error 3: line 37, column 22 of lib/projects/project_component.dart and parts: Expected a statement
final cmpClass = class DynamicComponent {};
^^^^^
Error 4: line 37, column 22 of lib/projects/project_component.dart and parts: Unexpected token 'class'
final cmpClass = class DynamicComponent {};
^^^^^
Error 5: line 37, column 28 of lib/projects/project_component.dart and parts: Expected to find ';'
final cmpClass = class DynamicComponent {};
^^^^^^^^^^^^^^^^
이 같은 새 구성 요소를 만들기 나를 위해 공통의 걸림돌이다. 아무도 다트로 어떻게 이룰 수 있겠습니까?
많은 감사! 이것은 클래스 선언과 관련된 문제를 해결합니다. 나는 여전히 전체 솔루션을 연구 중이고 일단 제대로 작동하면 최종 버전을 게시 할 것입니다. – DarthKipsu