ngIf 문과 함께 다른 구성 요소를 사용하는 구성 요소가 있습니다. ngIf가 true로 평가되면 두 번째 구성 요소 만로드하려고합니다.각도 2의 부품에 게으른 하중을 가하는 방법이 있습니까?
편집 : 필요한 항목을 거의 수행 할 수있는 문서를 찾았습니다 : https://medium.com/@matanlurey/lazy-loading-with-angular-dart-14f58004f988. 그러나 라이브러리를로드 한 후에는 구성 요소의 전체보기가 필요합니다. 필자의 경우, 부모 컴포넌트의 html에있는 특정 위치에 그것을 삽입해야한다. 같은
뭔가 :
import '../other/edit_component.dart' deferred as otherEdit;
@Component(
selector: 'edit-component',
template: '<other-component *ngIf="canOther"></other-component>
<button type="button" (click)="go()"></button>',
directives: const [
otherEdit.OtherComponent
]
)
class EditComponent {
@Input()
bool canOther = false;
go() {
otherEdit.loadLibrary();
canOther = true;
}
}
실제로 지시어가 아닌 구성 요소를 게으른로드하려고합니다. 당신은 지시문이 게으른 로딩을 트리거하기를 원합니다. –
올바른, 구성 요소. 실수로, 그것을 편집 할 것입니다. – Jonathan