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 { createStore } from 'redux' | |
import { currencyReducer } from './reducers/currencyReducer.js'; | |
const appStore=createStore(currencyReducer); | |
export default appStore; |
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 { Provider } from 'react-redux'; | |
import appStore from './store'; | |
..... | |
const AppWithStore=()=>( | |
<Provider store={appStore}> | |
<App /> |
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
class App extends Component { | |
render() { | |
return ( | |
<div> | |
<Counter /> | |
</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
import { FormControl } from '@angular/forms'; | |
export function zipCodeValidator(ctrl: FormControl) { | |
if (ctrl.value === 123456) { | |
return null; | |
} | |
return { | |
zipCode: { validCode: 123456 } | |
}; |
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
<div *ngIf="addressObj.get('pincode').touched"> | |
<small *ngIf="addressObj.get('pincode').hasError('required')">Pincode is required</small> | |
<small *ngIf="addressObj.get('pincode').hasError('zipCode')"> | |
allowed pincode is {{addressObj.get('pincode').getError('zipCode').validCode}} | |
</small> | |
</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
import { Directive } from '@angular/core'; | |
import { NG_VALIDATORS } from '@angular/forms'; | |
import { zipCodeValidator } from '../forms/validators'; | |
@Directive({ | |
selector: '[appZipCode][ngModel]', | |
providers: [ | |
{ | |
provide: NG_VALIDATORS, | |
useValue: zipCodeValidator, | |
multi: true |
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
// using lodash library | |
const reMap=(custom_schema,conversion_schema,data)=>{ | |
const actualKeys=conversion_schema; | |
const availableKeys=_.values(custom_schema); | |
const missingKeys=_.difference(actualKeys,availableKeys); | |
if(!_.isArray(data)) | |
return createObject(custom_schema,missingKeys,data); | |
else | |
return reMapAll(custom_schema,missingKeys,data); | |
} |
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 schema={pid:'productId',pname:'productName',pimg:'productImage',pCat:'productCategory'}; |
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 product=['productId','productName','productStock','productImage','productCost']; |
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
// array | |
const data=[ | |
{pid:1000,pname:'test',pimg:'demo',pCat:'123'}, | |
{pid:1001,pname:'test 1',pimg:'demo 1',pCat:'123'}, | |
{pid:1002,pname:'test 2',pimg:'demo 2',pCat:'123'}, | |
]; | |
// single object | |
const data={pid:1000,pname:'test',pimg:'demo',pCat:'123'} |