app
photo
photo.component.ts
import { Component } from "@angular/core";
@Component({
selector:'ap-photo',
templateUrl:'photo.component.html'
})
export class PhotoComponent {
description = 'Leão';
url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Sultan_the_Barbary_Lion.jpg/440px-Sultan_the_Barbary_Lion.jpg';
}
photo.component.html
<img class="img-thumbnail" [src]="url" [alt]="description">
app.component.html
<ap-photo></ap-photo>
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { PhotoComponent } from './photo/photo.component';
@NgModule({
declarations: [
AppComponent,
PhotoComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }