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

View File

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