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
@Directive({ selector: '[hasRole]' }) | |
export class HasRoleDirective { | |
constructor( | |
private templateRef: TemplateRef<any> | |
private viewContainer: ViewContainerRef) {} | |
@Input('hasRole') | |
roles: string[]; | |
@Input('hasRoleElse') |
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
// Check if ball is inside from left side | |
ball.x + 2 * ball.radius > brick x | |
// Decrease by dx and check if position was on left side of brick x | |
ball.x + 2 * ball.radius - ball.dx <= brick.x; | |
// Similarly for right side | |
ball.x < brick.x + brick.width | |
ball.x - ball.dx >= brick.x + brick.width |
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, { useState, useRef, useEffect } from 'react'; | |
import '@reactangular/elements'; | |
const App = () => { | |
const [counter, setCounter] = useState(0); | |
const buttonRef = useRef(null); | |
useEffect(() => { | |
const handleEvent = () => setCounter(counter + 1); | |
const btnAddToCart = buttonRef.current; |