git remote rm origin git remote add origin http://... git push -u origin --all
git remote rm origin git remote add origin http://... git push -u origin --all
import { YourNameComponent } from './pages/admin/YourName/YourName.component';
appRoutes: Routes = [
{
path: 'admin/YourName',
component: YourNameComponent,
canActivate: [AuthenticationGuard],
data: { title: 'Your Name', isNew: true }
},
@NgModule({
declarations: [
YourNameComponent dotenv packageREACT_APP_MOCK_API_URL=data1
REACT_APP_REST_KEY=data2
const key = process.env.REACT_APP_REST_KEY;
const mockUrl = process.env.REACT_APP_MOCK_API_URL;
Important!
Variable name MUST begin with "REACT_APP_"
(Initially I called variable MOCK_API_URL. It took me few hours to figure out why key contained value and mockUrl was undefined.)
takeown /F "D:\Program Files" /A /R /D Y
icacls "D:\Program Files" /T /grant administrators:F
rd /s /q "D:\Program Files"
Źródło: https://superuser.com/a/1028115
import { Component, forwardRef, Input, OnInit } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
@Component({
selector: 'app-password-input',
templateUrl: './password-input.component.html',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => PasswordInputComponent),
multi: true
}
]
})
export class PasswordInputComponent implements OnInit, ControlValueAccessor {
constructor() {}
writeValue(obj: any): void {
this.Value = obj;
}
registerOnChange(fn: any): void {
this.onChange = fn;
}
registerOnTouched(fn: any): void {
this.onTouch = fn;
}
setDisabledState?(isDisabled: boolean): void {
this.disabled = isDisabled;
}
onChange: any = () => {};
onTouch: any = () => {};
disabled?: boolean;
ngOnInit(): void {}
/** Password value */
public value: string;
set Value(val) {
// this value is updated by programmatic changes
if (val !== undefined && this.value !== val) {
this.value = val;
this.onChange(val);
this.onTouch(val);
}
}
get Value(): string {
return this.value;
}
}
@Output() public selectedStep: EventEmitter<number> = new EventEmitter<number>();
How to write CustomEvent in plain HTML + JS page, so that it would eg. display step number to console?
<script>
// trigger this function, when event is emitted from inside custom-element
function stepChanged(e) {
console.log('Current step: ' + e);
}
document.addEventListener("DOMContentLoaded", function() {
// Handler when the DOM is fully loaded
let element = document.querySelector("custom-element");
element.addEventListener("selectedStep", event => {
stepChanged(event.detail);
});
});
</script>
<custom-element></custom-element>
Important to remember: addEventListener first parameter is the name of Output detail property of second paramenter /**
* Generate random lowercase word
* @param {number} length Word length
* @returns Random n-letter word
*/
randomWord(length: number): string {
let result = '';
for (let index = 0; index < length; index++) {
// one of 26 en letters, 'a' = 97
const ascii = Math.floor(Math.random() * 26 + 97);
result += String.fromCharCode(ascii);
}
return result;
}
storybook-addon-preview. However, I there is one story that has no code preview and it displays "No Preview found" message.
export default {
title: 'Some title',
parameters: { options: { showPanel: false } }
};
export default {
title: 'Tooltip',
decorators: [
moduleMetadata({
// imports both components to allow component composition with storybook
declarations: [TooltipComponent],
imports: [NgbModule]
}),
],
};
var myLocation = DbGeography.FromText(string.Format("POINT({0} {1})", lon, lat));
var result = (from u in _db.Restaurants
orderby u.Location.Distance(myLocation)
where u.Location.Distance(myLocation) < distance
select u).Take(limit).ToList();
distance is a double and its value is in meters.