Permalink
Browse files

todoItem added, without ngFor

  • Loading branch information...
Żaneta Jażdżyk
Żaneta Jażdżyk committed Nov 7, 2017
1 parent 3cfcb9d commit 3641141b7c5b577f9b424f9ffed24f448b07da02
@@ -9,7 +9,12 @@ export class AppComponent {
title = 'Todo sample app';
lists = {
todo: {
name: 'To do'
name: 'To do',
tasks: [
'Todo #1',
'Todo #2',
'Todo #3'
]
}
}

@@ -3,11 +3,13 @@ import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { TodoListComponent } from './todo-list/todo-list.component';
import { TodoItemComponent } from './todo-list/todo-item/todo-item.component';

@NgModule({
declarations: [
AppComponent,
TodoListComponent
TodoListComponent,
TodoItemComponent
],
imports: [
BrowserModule
@@ -0,0 +1,4 @@
<div>
<input type="checkbox" name="task1">
<label for="task1">{{ task }}</label>
</div>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { TodoItemComponent } from './todo-item.component';

describe('TodoItemComponent', () => {
let component: TodoItemComponent;
let fixture: ComponentFixture<TodoItemComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TodoItemComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(TodoItemComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,16 @@
import { Component, OnInit, Input } from '@angular/core';

@Component({
selector: 'app-todo-item',
templateUrl: './todo-item.component.html',
styleUrls: ['./todo-item.component.scss']
})
export class TodoItemComponent implements OnInit {
@Input() task: any;

constructor() { }

ngOnInit() {
}

}
@@ -1 +1,4 @@
<h2>{{ list.name }}</h2>
<app-todo-item [task]="list.tasks[0]"></app-todo-item>
<app-todo-item [task]="list.tasks[1]"></app-todo-item>
<app-todo-item [task]="list.tasks[2]"></app-todo-item>

0 comments on commit 3641141

Please sign in to comment.