Exercise Solutions: Angular, Lesson 1¶
Part 1: Modify the CSS¶
Change the movie list text by adjusting the code in
movie-list.component.css
to accomplish the following:The text for the heading and list items can be any color EXCEPT black. (HINT: Take advantage of the
movies
class).The movie list should have a centered heading.
The font size should be large enough to easily read.
1 2 3 4 5 6 7 8
.movies { color: purple; font-size: 1.3vw; } h3 { text-align: center; }
Add More Movies¶
Add two more items to the
movies
array.movies = ['The Manchurian Candidate', 'Oceans 8', 'The Incredibles', 'Hidden Figures'];
Complete the fav-photos
Component¶
The
fav-photos
component has been generated, but it is incomplete. The page needs more images, which also need to be smaller in size.In the
FavPhotosComponent
class, assign a better section heading to thephotosTitle
variable.photosTitle = 'Random Images';
In the
.html
file for this component, use placeholders in theimg
tags to display your chosen images.<img src="{{image1}}" alt="Oops! Missing photo!">
Use the
.css
file for this component to make all the images be the same size.img { width: 40%; height: auto; }
Part 2: Add More Components¶
The page needs a set of links to favorite websites.
Generate a
fav-links
component. Openfav-links.component.ts
and shorten the tag name to justfav-links
.@Component({ selector: 'fav-links', templateUrl: './fav-links.component.html', styleUrls: ['./fav-links.component.css'] })
Inside each
<a>
tag, set thehref
attribute equal to a placeholder for an element in thefavLinks
array:<a href = "{{favLinks[0]}}">LaunchCode</a> <br> <a href = "{{favLinks[1]}}">WebElements</a>
Part 3: Rearrange the Components¶
Rearrange the tags
fav-photos
,fav-links
,page-title
, etc. to create a specific page layout:app.component.html
has<div>
tags to set up a three-column row. Use this to arrange the movie list, images, and chore list.<div class="col-3"> <movie-list></movie-list> </div> <div class="col-3"> <fav-photos></fav-photos> </div> <div class="col-3"> <chores-list></chores-list> </div>
Add a horizontal line below the three lists with the
<hr>
tag.<!-- three lists are here --> </div> <hr> <fav-links></fav-links>