Exercise Solutions: Angular, Lesson 1¶
Part 1: Modify the CSS¶
Change the movie list text by adjusting the code in
movie-list.component.cssto accomplish the following:The text for the heading and list items can be any color EXCEPT black. (HINT: Take advantage of the
moviesclass).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
moviesarray.movies = ['The Manchurian Candidate', 'Oceans 8', 'The Incredibles', 'Hidden Figures'];
Complete the fav-photos Component¶
The
fav-photoscomponent has been generated, but it is incomplete. The page needs more images, which also need to be smaller in size.In the
FavPhotosComponentclass, assign a better section heading to thephotosTitlevariable.photosTitle = 'Random Images';
In the
.htmlfile for this component, use placeholders in theimgtags to display your chosen images.<img src="{{image1}}" alt="Oops! Missing photo!">
Use the
.cssfile 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-linkscomponent. Openfav-links.component.tsand 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 thehrefattribute equal to a placeholder for an element in thefavLinksarray:<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.htmlhas<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>
