Last active
July 5, 2017 14:42
-
-
Save CesarAfonso/1865041a15af60600cb7b538018bdccd to your computer and use it in GitHub Desktop.
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
<template> | |
<span>This is an APP</span> | |
</p> | |
<compose view-model.bind="'parentForm'"></compose> | |
</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
import { autoinject } from 'aurelia-framework'; | |
@autoinject | |
export class App { | |
} |
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
<template> | |
<label> Price : </label> | |
<input value.bind="model.data.price"> | |
<p/> | |
<label> VAT : </label> | |
<input value.bind="model.data.vat"> | |
<p/> | |
</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
import { autoinject } from 'aurelia-framework'; | |
@autoinject | |
export class ChildForm1 { | |
activate(model) | |
{ | |
this.model = model; | |
} | |
validateRules (){ | |
if(this.model.data.price != '' && this.model.data.vat == '' ) | |
this.model.validateMessage = 'VAT is mandatory'; | |
} | |
} |
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
<template> | |
<label>Address : </label> | |
<input value.bind="model.data.address"> | |
<p/> | |
<label>Phone : </label> | |
<input value.bind="model.data.phone"> | |
<p/> | |
</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
import { autoinject } from 'aurelia-framework'; | |
@autoinject | |
export class ChildForm2 { | |
activate(model) | |
{ | |
this.model = model; | |
} | |
validateRules (){ | |
if(this.model.data.phone != '' && this.model.data.address == '' ) | |
this.model.validateMessage = 'Address is mandatory'; | |
} | |
} |
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
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script> | |
require(['aurelia-bootstrapper']); | |
</script> | |
</body> | |
</html> |
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
<template> | |
<button click.delegate="changeChildForm1()">Change Child Form 1</button> | |
<button click.delegate="changeChildForm2()">Change Child Form 2</button> | |
<p/> | |
<p/> | |
<form> | |
<label>User : </label> | |
<input value.bind="model.data.user"> | |
<p/> | |
<compose view-model.bind="childFormVM" view-model.ref="childFormInstance" model.bind="model"></compose> | |
<button click.delegate="save()">Save</button> | |
<p/> | |
<span> Validation Message : ${model.validateMessage}</span> | |
</form> | |
<p/> | |
<span>Price : ${model.data.price}</span><p/> | |
<span>Vat : ${model.data.vat}</span><p/> | |
<span>Phone : ${model.data.phone}</span><p/> | |
<span>Address : ${model.data.address}</span><p/> | |
</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
import { autoinject } from 'aurelia-framework'; | |
@autoinject | |
export class ParentForm { | |
model = { | |
validateMessage : '', | |
data : { | |
user : 'My Name' | |
} | |
}; | |
childFormVM = 'childForm1'; | |
validateMessage = ''; | |
changeChildForm1() { | |
this.childFormVM = 'childForm1'; | |
} | |
changeChildForm2() { | |
this.childFormVM = 'childForm2'; | |
} | |
save(){ | |
this.validateRules(); | |
this.childFormInstance.currentViewModel.validateRules(); | |
} | |
validateRules (){ | |
this.model.validateMessage = 'Validate by parent'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment