[src]=""
or [(ngModel)]= ""
we can create our own. - create a new sub-component. You can create it manually or using cli command:
ng g c yourComponent --spec false
. Now you can use the<app-yourComponent>
tag in your app-component.html - In the sub-component create an object you want to bind for e.g user
- Add
@Input()
decorator before the object declaration - your HTML file will look like this when binding element object(in serverComponent) and serverElements array(in app.component)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component, OnInit, Input} from '@angular/core'; | |
@Component({ | |
selector: 'app-server-element', | |
templateUrl: './server-element.component.html', | |
styleUrls: ['./server-element.component.css'] | |
}) | |
export class ServerElementComponent implements OnInit { | |
@Input() element: {type: string, name: string, content:string}; | |
constructor() { } | |
ngOnInit() { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
<div class="col-xs-12"> | |
<app-server-element | |
*ngFor="let serverElement of serverElements" | |
[element]="serverElement"></app-server-element> | |
</div> | |
</div> |