简体   繁体   中英

Change Angular2 Material Component ( e.g. Select controller ) outside from Angular

If it is possible...

I have a site: www.recognitiongame.com I have started to use Angular2 Material Components ( Autocomplete, Button... ).

I want to change the "Main theme:" DropDownlist to Angular2 Material Select Component.

I have this:

<mat-select placeholder="Main theme:" [(ngModel)]="selectedValue">
 <mat-option *ngFor="let maintheme of mainthemes" [value]="maintheme.id">
  {{ maintheme.value }}
</mat-option>   

How can I access the Angular2 Component "selectedValue" variable from outside? Something like this:

<html>
<body>
<my-app></my-app>
...
<script type="text/javascript">
 **Change the selectedValue?**
</script>
</body>
</html>
public _selectedValue = window['selectedValue']
public set selectedValue(_selectedValue){
   this._selectedValue = _selectedValue;
   window['selectedValue'] = _selectedValue;
}

public get selectedValue(){
   return this._selectedValue;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM