如何将假值赋给formio形式 [英] how to give dummy values to formio form
问题描述
我已经使用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
例如:-
在angularJS中,我们可以像$scope.ngModel
一样使用ng-model
进行访问
在formio中,我们如何在组件中访问它.
Ex:-
In angularJS, we can access that with ng-model
like $scope.ngModel
in formio how can we access that in a component.
推荐答案
是的,我们甚至可以在组件级别实现这一目标.
Yes, we can achieve this in component level even.
如下更改您的html
change your html as below
<formio [form]="obj" [submission]="submission"/>
在组件中添加以下内容
submission: any;
showData () {
this.submission = {
data: {
userName: 'Joe',
password: 'Smith'
}
};
}
它应该在页面中显示数据.
it should display the data in page.
快乐编码:)
这篇关于如何将假值赋给formio形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!