Use the restaurant menu REST API to create a master/detail view pair.
Your application should have 3 views (i.e., 3 view states):
- home (
home
) - categories list (
categories
) - items list (
items
)
When the user goes to /
path in your application, a home screen should be
shown. The home screen should have a link to a list of categories of menu
items in the restaurant. Clicking that link would obviously take the user to
the /categories
view.
The categories view should list all available categories of items on the
menu. Each listing should be a link. Clicking that link should take the user
to the /items
view. Note that since what the items
view state shows is
dependent on which category the user clicked, the URL mapping will need to
have a parameter in it. I.e., don't take the URLs I am listing in the
assignment description as literal URLs. They are just naming hints.
Make sure that if, while viewing the list of menu items for a particular category, the user copies the URL in the browser's address bar and pastes it into a new tab or a different browser, that the view is the same as the original one.
- Name your app
MenuApp
. - You must follow the 1 artifact per file rule.
- Create a file called
menuapp.module.js
and declare an Angular module to match yourng-app
declaration.- Depends on the
data
module
- Depends on the
- Create
data.module.js
file and declare another module in it calleddata
- Create
menudata.service.js
file and create a service calledMenuDataService
in it.- declare on the
data
module. It should have two methods: getAllCategories
- returns an$http
promise from:https://davids-restaurant.herokuapp.com/categories.json
getItemsForCategory(categoryShortName)
- returns a$http
promise:https://davids-restaurant.herokuapp.com/menu_items.json?category=
categoryShortName
value was passed in as an argument
- declare on the
- Create
categories.component.js
with acategories
component that shows all available categories - Create
items.component.js
with aitems
componnent that shows all of the menu items for a particular category. - The
categories
and theitems
components should NOT directly use theMenuDataService
to fetch their own data. Instead, the proper data should be simply passed into the component. (Hint: use the one-way<
binding). - Create
routes.js
file and configure your routes and view states in it. These routes should be defined in theMenuApp
module.- Hint: The
home
state will not need a controller. Just a template. - Hint: The
categories
state can have acontroller
as well as aresolve
. The resolve will use theMenuDataService
to retrieve categories and inject them into the controller. The controller can then expose the retrieved categories object such that it can be simply passed into thecategories
component. - Hint: The
items
state can have the same type of setup as thecategories
state.
- Hint: The