This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import 'ExampleComponent.css'; | |
export default class ExampleComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { message: 'Hello from component!' }; | |
} | |
render() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from 'angular2/core'; | |
@Component({ | |
selector: 'component-placeholder', | |
templateUrl: 'app/example.template.html', | |
styleUrls: [ 'app/example.css' ] | |
}) | |
export class ExampleComponent { | |
public message = 'Hello from component!'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Two way binding:</h1> | |
<div>{{message}}</div> | |
<label for="new-message">Type: message</label> | |
<input type="text" [(ngModel)]="message" id="new-message" /> | |
<h1>Lists:</h1> | |
<ul> | |
<li *ngFor="#item of nameList"> | |
{{item.name}} | |
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render() { | |
return ( | |
<div className="container"> | |
<p>{this.state.message}</p> | |
</div> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReactDOM.render( | |
<Router history={browserHistory}> | |
<Route path="/" component={App}> | |
<Route path="about" component={About}/> | |
<Route path="users" component={Users}> | |
<Route path="/user/:userId" component={User}/> | |
</Route> | |
<Route path="*" component={NoMatch}/> | |
</Route> | |
</Router>, document.getElementById('app')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ ... }) | |
@RouteConfig([ | |
{ path: '/', name: 'Home', component: Home }, | |
{ path: '/users', name: 'Users', component: About }, | |
{ path: '/user:id', name: 'User' component: User } | |
]) | |
export class App { | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<router-outlet></router-outlet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tempObj = { | |
prop1: 1, | |
prop2: 2, | |
}; | |
const tempFunc(arg1) { | |
return arg1 + 2; | |
} | |
const defaultFunc(arg2) { |