问题
I have created a username and password with submit button page using formio
and I have shown in the page by taking that script from the database. the page is visible now. But I want to show a dummy username and password when I click on a button.
But I have achieved like whenever the page loads the data will fill by adding below.
<formio [form]="obj"[submission]='{
"data": {
"userName": "Joe",
"password": "Smith"
}
}'>
But I want to fill the data when I have clicked on a button. Actually my intention is that I want to access that username in my component. How can I access that username
Ex:-
In angularJS, we can access that with ng-model
like $scope.ngModel
in formio how can we access that in a component.
回答1:
Yes, we can achieve this in component level even.
change your html as below
<formio [form]="obj" [submission]="submission"/>
add the following in your component
submission: any;
showData () {
this.submission = {
data: {
userName: 'Joe',
password: 'Smith'
}
};
}
it should display the data in page.
Happy coding :)
来源:https://stackoverflow.com/questions/60650006/how-to-give-dummy-values-to-formio-form