s8e111 callbacks

This commit is contained in:
Tyrel Souza 2018-04-17 21:44:21 -04:00
parent abd9b87b96
commit e421d3c06b
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0
2 changed files with 16 additions and 2 deletions

View File

@ -6,7 +6,11 @@
<hr>
<div class="row">
<div class="col-xs-12 col-sm-6">
<app-user-detail :name="name" @nameWasReset="name = $event"></app-user-detail>
<app-user-detail
:name="name"
@nameWasReset="name = $event"
:resetFn="resetName"
></app-user-detail>
</div>
<div class="col-xs-12 col-sm-6">
<app-user-edit></app-user-edit>
@ -29,6 +33,9 @@
changeName(){
this.name = "TyrelSouza"
},
resetName(){
this.name = 'Tyrel';
}
},
components: {
appUserDetail: UserDetail,

View File

@ -2,8 +2,9 @@
<div class="component">
<h3>You may view the User Details here</h3>
<p>Many Details</p>
<p>User Name: {{ name }}</p>
<p>User Name: {{ switchName() }}</p>
<button @click="resetName">Reset Name</button>
<button @click="resetFn()">Reset Name Fn</button>
</div>
</template>
@ -12,9 +13,15 @@
props: {
name: {
type: String,
},
resetFn: {
type: Function
}
},
methods: {
switchName(){
return this.name.split("").reverse().join("");
},
resetName(){
this.name = 'Tyrel';
this.$emit('nameWasReset', this.name)