This file contains hidden or 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
| // Angular 1 | |
| const module = angular.module('myModule', []); | |
| module.component('myComponent', { | |
| bindings: { | |
| name: '@', // String binding | |
| age: '<', // One-way binding | |
| color: '@favouriteColor' // Renamed string binding | |
| }, | |
| controller() { | |
| this.name = this.name || 'User'; // Default value |
This file contains hidden or 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
| // Angular 1 | |
| const module = angular.module('myModule', []); | |
| module.component('myComponent', { | |
| controller() { | |
| this.message = 'Hello World!'; | |
| this.sayHello = () => { | |
| alert('Hello World!'); | |
| }; | |
| }, | |
| template: '<div ng-click="$ctrl.sayHello()">{{$ctrl.message}}</div>' |
This file contains hidden or 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
| // Angular 1 | |
| const module = angular.module('myModule', []); | |
| module.component('myComponent', { | |
| templateUrl: 'path/to/my/template.html' | |
| }); | |
| /***************************************************************/ | |
| // Angular 2 | |
| import {Component} from '@angular/core'; |
This file contains hidden or 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
| // Angular 1 | |
| const module = angular.module('myModule', []); | |
| module.component('myComponent', { | |
| template: '<div>Hello World!</div>' | |
| }); | |
| /***************************************************************/ | |
| // Angular 2 | |
| import {Component} from '@angular/core'; |
This file contains hidden or 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
| $stateProvider.state('a-state', { | |
| url: "/a-url", | |
| template: '<a-react-container></a-react-container>' | |
| }) |
This file contains hidden or 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 {stateGo} from 'redux-ui-router'; | |
| const stateMap = { | |
| '/': 'index', | |
| '/page1': 'page1', | |
| '/page2': 'page2' | |
| } | |
| const push = url => { | |
| // getPath() and getParams() are example functions |
This file contains hidden or 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 {setLocation} from 'ng-redux-router'; | |
| const push = url => setLocation(url); | |
| export {push} |
This file contains hidden or 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
| app.directive('myComponent', ['reactDirective', '$ngRedux', function(reactDirective, $ngRedux) { | |
| return reactDirective(MyComponent, null, {}, {store: $ngRedux}); | |
| }]); |
This file contains hidden or 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 module = angular.module('toggle', ['react']); | |
| const Toggle = (props) => ( | |
| <div onClick={() => props.onToggle(!props.value)}> | |
| <span className={props.value ? 'selected' : ''}> | |
| {props.trueLabel || 'Yes'} | |
| </span> | |
| <span className={!props.value ? 'selected' : ''}> | |
| {props.falseLabel || 'No'} | |
| </span> |
This file contains hidden or 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
| <toggle value="value" | |
| true-label="'True'" | |
| false-label="'False'" | |
| on-toggle="::onToggle"> | |
| </toggle> |