Angular2 View layer package for Cerebral
You can access the webpage at http://cerebraljs.com/
You can download the Chrome debugger here.
npm install cerebral-view-angular2
All examples are shown with Typescript syntax.
// Your cerebral controller instance
import controller from './controller';
import {register} from 'cerebral-view-angular2';
// Your main application component
import AppComponent from './components/app.component';
// Register the controller with the decorator
register(controller);
// Bootstrap the angular2 app
document.addEventListener('DOMContentLoaded', () => {
bootstrap(AppComponent)
.catch(err => console.error(err));
});
Use the decorator to pass state and signals to the component
import {Component} from 'angular2/core';
import {Decorator as Cerebral} from 'cerebral-view-angular2';
@Cerebral({
isLoading: ['isLoading'],
user: ['user'],
error: ['error']
})
class AppComponent {
public signals;
public state;
}
You can access your signals with:
this.signals.firstSignal();
this.signals.otherSignal();
You can access the state with:
this.state.isLoading;
this.state.user;
this.state.error;
Clone the repo
git clone https://github.com/cerebral/cerebral-view-angular2.git
Install dependencies
npm install
Start the server. It will listen on localhost:3000
npm start