Skip to content

Instantly share code, notes, and snippets.

View Gbuomprisco's full-sized avatar
🚀
Building stuff

Giancarlo Buomprisco Gbuomprisco

🚀
Building stuff
View GitHub Profile
@Gbuomprisco
Gbuomprisco / in-and-out.ts
Created July 20, 2016 01:25
Inputs and Outputs
import {
Component,
Input,
Output
} from '@angular/core';
@Component({
selector: 'my-component',
template: `
<span>Input: {{ option }}</span>
import {
Component
} from '@angular/core';
@Component({
selector: 'my-component',
template: `<ng-content></ng-content>`
})
export class MyComponent {
ngOnInit() {
import {
Component
} from '@angular/core';
class MyProvider {
doSomething() {
// it's doing something
}
}
import {
Component,
ViewChild,
ContentChild
} from '@angular/core';
@Component({
selector: 'view-child',
template: `<ng-content></ng-content>`
})
import {
Component,
forwardRef,
Inject
} from 'angular2/core';
@Component({
selector: 'child',
template: `
<ng-content></ng-content>
import {
Component,
Http
} from 'angular2/core';
@Component({
selector: 'app',
template: `
<ng-content></ng-content>
`,
import {
Component,
Renderer
} from '@angular/core';
@Component({
selector: 'my-component',
template: `
<input #input type="text" />
`
import {
Component
} from '@angular/core';
@Component({
selector: 'child-one',
template: `
<ng-content></ng-content>
`
})
const CREATE_TODO = 'CREATE_TODO';
const MARK_DONE = 'MARK_DONE';
export class CreateTodoAction {
public type = CREATE_TODO;
constructor(public payload: Todo) {}
}
export class MarkTodoDoneAction {
import { createReducer, Action } from 'typed-reducer';
import { CreateTodoAction, MarkTodoDoneAction } from './todo.actions';
class TodoReducer {
@Action
public createTodo(state: Todo[], action: CreateTodoAction): Todo[] {
return [ ...state, action.payload ];
}
@Action