Last active
December 1, 2015 16:08
-
-
Save mattstauffer/21e9ca43563f204995ad 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
new Vue({ | |
el: '#assignment-creator', | |
data: { | |
trainee: {} | |
}, | |
ready: function () { | |
this.trainee = TrainRemote.trainee; | |
} | |
}); |
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
<script> | |
var TrainRemote = { | |
trainee: { | |
id: 5, | |
name: 'Matt Stauffer' | |
} | |
}; | |
</script> | |
<div id="assignment-creator" v-cloak></div> |
Or just...
<assignment-creator trainee-id="{{ $trainee->id }}" trainee-name="{{ $trainee->name }}"></assignment-creator>
Vue.component('AssignmentCreator', {
props: ['traineeId', 'traineeName'],
// etc.
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, my question is: What's the idiomatic (suggested/in-line with Vue styles/practices) way to pass outside data to a Vue instance?
I know if it were a sub-component I'd make it a prop, and then just add it as a property to the
<div id="assignment-creator">
element.But since this is the parent component, is there a better way to pass outside data in (assuming you're not making HTTP calls)?