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
<div id="container"/> | |
<script> | |
var button = document.createElement('button'); | |
var textNode = document.createTextNode('Click Me!'); | |
button.appendChild(textNode); | |
button.className = 'mdl-button mdl-js-button mdl-js-ripple-effect'; | |
componentHandler.upgradeElement(button); | |
document.getElementById('container').appendChild(button); | |
</script> |
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
<!-- Simple MDL Progress Bar --> | |
<div id="p1" class="mdl-progress mdl-js-progress"></div> | |
<script> | |
document.querySelector('#p1').addEventListener('mdl-componentupgraded', function() { | |
this.MaterialProgress.setProgress(44); | |
}); | |
</script> |
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, | |
Input, | |
ViewChild, | |
AfterViewInit, | |
OnChanges, | |
SimpleChange | |
} from 'angular2/core'; | |
@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
// angular < 1.5.0 : | |
//////////////////////////////// | |
// file : demo.directive.js | |
//////////////////////////////// | |
import {DEMO_CONTROLLER_NAME} from './demo.controller'; | |
export const DEMO_DIRECTIVE_NAME = 'demoDirective'; |
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
// with angular >= 1.5.x | |
//////////////////////////////// | |
// file : demo.component.js | |
//////////////////////////////// | |
export const DEMO_COMPONENT_NAME = 'demoComponent'; | |
// before angular 1.5 component : directive was the way to create component | |
export const demoComponent = { | |
template : ` |
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
// Angular2 | |
import {Component, Input} from 'angular2/core'; | |
import {$service1} from './service1'; | |
import {$service2} from './service1'; | |
@Component({ | |
selector : 'demo-directive', | |
providers : [$service1, $service2], | |
template : ` |
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
function sortByDateDesc(histo) { | |
return histo.sort( | |
(a, b) => { | |
if (a.date < b.date) { | |
return 1; | |
} | |
if (a.date > b.date) { | |
return -1; | |
} | |
return 0; |
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 Beacons from 'react-native-beacons-manager'; | |
class RNbeaconArticle extends Component { | |
// ... | |
componentWillMount(){ | |
// | |
// ONLY non component state aware here in componentWillMount | |
// | |
// Request for authorization while the app is open | |
Beacons.requestWhenInUseAuthorization(); |
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
// ... | |
componentDidMount() { | |
// Ranging: Listen for beacon changes | |
this.beaconsDidRange = DeviceEventEmitter.addListener( | |
'beaconsDidRange', | |
(data) => { | |
this.setState({ | |
dataSource: this.state.dataSource.cloneWithRows(data.beacons) | |
}); | |
} |
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
'use strict'; | |
import React, { | |
Component | |
} from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, | |
View, | |
Text, |