I have three root components that are loaded by the root root AppModule.
AppModule
How are you going to specify a parameter @Input()for one of these components?
@Input()
Neither
<app-modal [id]="'hard-coded value'"></app-modal> <app-modal [id]="constantExportedByAppmodule"></app-modal>
selected AppModalComponent:
AppModalComponent
@Input() id: string;
It is undefined.
As far as I know, you cannot pass @Input () to the boot component.
But you can use another way to do this - pass the value as an attribute.
index.html:
<my-app myAttribute="myAttributeValue"> <div>Loading...</div> </my-app>
app.component.ts:
@Component({ selector: 'my-app', templateUrl: 'app.component.html', styleUrls: ['app.component.css'] }) export class AppComponent { constructor(private elementRef:ElementRef) { let myAttribute = this.elementRef.nativeElement.getAttribute('myAttribute'); } }
As Grigory Gossart said, you cannot transfer @Input data as usual for loaded components.
, , @Input angular. , / HTML, , @Input, .
angular, , , - , . , - , , (3) . @Input . .
, @Injectable , , . , .
: , , , , @Injectable. , . angular 2
Source: https://habr.com/ru/post/1691104/More articles:Sum all column values in vector - rWhy does registering a module disable rewriting? - c #Data binding between html element property and script value not synchronized - javascriptThe input variable does not accept the values from the @Input property in the template. Angular 5 - angularПроблема TLS при вызове API-интерфейсов с платой из моего локального env - pythonУдаление заголовка и нижнего колонтитула и серый цвет фона из конвертированного PDF файла с использованием безголового хрома - google-chrome-headlesshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1691106/possible-data-race-between-writes-to-the-same-address-in-memory&usg=ALkJrhiV7uegyp4B-gJW1SaRbBWxD_rjMAHow to annotate default value inside Android class object? - androidTOSVersion gives the wrong result - delphiHow to count the number of months during which a particular person has been in service - pythonAll Articles