- clone branch: https://github.com/manekinekko/angular2-codelab/tree/step-1
- create and add a root component
- name it
Ng2CodelabApp - store it in
src/app/ng2-codelab.ts - use selector
<app></app> - create the template
src/app/ng2codelab.html- use template HTML from home.html#L17-L80
- bootstrap your application in
src/app.ts - check solution: https://github.com/manekinekko/angular2-codelab/tree/step-1-solution
- diff: https://github.com/manekinekko/angular2-codelab/compare/step-1...step-1-solution
- clone branch: https://github.com/manekinekko/angular2-codelab/tree/step-2
- create and add a dump component
- name it
ThemeCard - store it in
src/app/components/theme-card/theme-card.ts - use selector
<theme-card></theme-card> - use template
src/app/components/theme-card/theme-card.html- use template HTML from home.html#L45-L59
- update the smart component
Home
- you can find this component in
src/app/components/home/home.ts - use template
src/app/components/home/home.html- Hint: use the dump
<theme-card></theme-card>
- Hint: use the dump
- use the provided service
src/app/services/technologies-store/technologies-store.ts
- check solution: https://github.com/manekinekko/angular2-codelab/tree/step-2-solution
- diff: https://github.com/manekinekko/angular2-codelab/compare/step-2...step-2-solution
- clone branch: https://github.com/manekinekko/angular2-codelab/tree/step-3
- create and add a dump component
- name it
QuestionCard - store it in
src/app/components/question-card/question-card.ts - use selector
<question-card></question-card> - use template
src/app/components/question-card/question-card.html- use template HTML from quizz.html#L34-L71
- add a route configurtion to the root component
Ng2CodelabApp
- add two routes:
HomeandQuestionCard
- update the
ThemeCardand it template to use the router - update the
Ng2CodelabApptemplate with the router directive - check the necessary router providers included in
src/app.ts
- we injected for you the router dependencies in app.tsL5-L6
- check solution: https://github.com/manekinekko/angular2-codelab/tree/step-3-solution
- diff: https://github.com/manekinekko/angular2-codelab/compare/step-3...step-3-solution
In this step, you are provided with all the necessary files containing the heavy work so you can focus on the basics. You can still take a momment and read this commit diff to understand what's really happening https://github.com/manekinekko/angular2-codelab/commit/39b9f0e6748825b51456d18dcd1cdd8d280fec7f
- clone branch: https://github.com/manekinekko/angular2-codelab/tree/step-4
- update the
QuestionCardcomponent and its template so it can display and navigate the questions correctly
- use
@Input()and@Output()in order to receive aquestion(which will be the current question) property and send ancheckedevent. - use the elvis operator to allow parsing undefined values, ie:
{{question?.title}}
- if you like challenges, you can re-implement these files:
src/app/components/technology/technology.tssrc/app/services/question-store/question-store.tssrc/app/services/session-store/session-store.ts
- check solution: https://github.com/manekinekko/angular2-codelab/tree/step-4-solution
- diff: https://github.com/manekinekko/angular2-codelab/compare/step-4...step-4-solution
- clone branch: https://github.com/manekinekko/angular2-codelab/tree/step-5
- create and add a smart component
- name it
Summary - store it in
src/app/components/summary/summary.ts - use an inline template
- use template HTML from summary.html#L50-L138
- Hint: reuse the
<question-card></question-card>component
- use a factory provider to get a new instance of the
QuestionsStore
- read the stored session using
SessionStore.read()
- use the
QuestionCardcomponent to display the saved answers - update the router configuration in
src/app/ng2-codelab.ts - check solution: https://github.com/manekinekko/angular2-codelab/tree/step-5-solution
- diff: https://github.com/manekinekko/angular2-codelab/compare/step-5...step-5-solution
- clone branch: https://github.com/manekinekko/angular2-codelab/tree/step-6
- add an input property (boolean) to the
QuestionCardto enable/disable a "preview mode"
- name it
preview - in preview mode, the checkboxes must be disabled
- in preview mode, the status of a choice is shown (see pipe below)
- add a pipe that shows a ✔ or ✘ if the given choice is correct or wrong, in the
QuestionCardcomponent
- name the class
MarkPipe - name the pipe
mark - store it in
src/app/pipes/mark-pipe/mark-pipe.ts
- check solution: https://github.com/manekinekko/angular2-codelab/tree/step-6-solution
- diff: https://github.com/manekinekko/angular2-codelab/compare/step-6...step-6-solution
- clone branch: https://github.com/manekinekko/angular2-codelab/tree/step-7
- update the content of the directive
StatusDirectivethat sets the color of a choice
- use selector
[status] - use the existing
<span></span>in question-card.html#L27 - if the choice is correct, set the color to green, otherwise set it to red
- use an
@Input()property to get a choice status (choice.isCorrect())
- use an
- use the
Rendererto set the stylethis.renderer.setElementStyle(nativeElement, styleProperty, value) - the directive is stored in
src/app/directives/status-directive/status-directive.ts