我正在对多个字段执行 CRUD 操作。我对所有字段都有 [(ngModel)]。
I am not interested to changed the name of the [(ngModel)] or assign any value in the
register.tsoredituser.tsfile while loading. Since I have made the form to save the values successfully in the register mode to the DB. I need to show the Inserted value in the Edit user Form and how can i perform that.
注意:我在两种表单中都有几个其他字段,即文本字段、textarea、密码,但不知何故,我在注册过程和编辑用户部分中设法将数据保存到数据库中,我也有为除 ion-select 之外的所有其他输入类型显示在编辑模式下插入的值。
例如: 在注册表单中,如果用户在编辑模式中选择了“男性”作为选项,我需要保留用户的输入权限,但表单再次显示“性别”而不是显示选定的值。
下面我列出了包含 ion-select 的两种形式以及我所做的努力。
register.html
<ion-item>
<ion-label floating>Gender</ion-label>
<ion-select [(ngModel)]="gender">
<ion-option value="Male">Male</ion-option>
<ion-option value="Female">Female</ion-option>
</ion-select>
</ion-item>
Edituser.html
我尝试了多种选择,但只有这个有效。但这不是我要找的。截至目前 [(ngModel)]="editUser.gender" 正在工作,并且在选项标签中选择了值,但这不是我想要的。我需要如下所示的模型 [(ngModel)]="gender" 但必须使用任何可用的方法来选择值。
<ion-item>
<ion-label floating>Gender</ion-label>
<ion-select [(ngModel)]="editUser.gender" name="gender">
<ion-option value="Male">Male</ion-option>
<ion-option value="Female">Female</ion-option>
</ion-select>
</ion-item>
editUser 包含来自数据库的 JSON 数据。
这里的主要缺点是,当我像这样提供模型名称时,提交表单时不会获取值。所以我需要选择在不更改 [(ngModel)] 的情况下选择值。
My aim is to keep the Model as I have in the register.html form [(ngModel)]="gender" for both the Register and as well as the Edit Form.
最佳答案
我不相信有一种方法可以完成您所描述的事情。但是,有一个解决方法。 Ionic Select 组件会发出 ionic 变化事件,引用 Output Events API 文档中的部分。这是实现。
<ion-select [(ngModel)]="gender" (ionChange)="onSelectChange($event)">
关于javascript - 在编辑模式下执行 CRUD 操作时选择 ionic 选择选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48621322/
我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co
我在使用omniauth/openid时遇到了一些麻烦。在尝试进行身份验证时,我在日志中发现了这一点:OpenID::FetchingError:Errorfetchinghttps://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username:undefinedmethod`io'fornil:NilClass重要的是undefinedmethodio'fornil:NilClass来自openid/fetchers.rb,在下面的代码片段中:moduleNetclass
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
这是在Ruby中设置默认值的常用方法:classQuietByDefaultdefinitialize(opts={})@verbose=opts[:verbose]endend这是一个容易落入的陷阱:classVerboseNoMatterWhatdefinitialize(opts={})@verbose=opts[:verbose]||trueendend正确的做法是:classVerboseByDefaultdefinitialize(opts={})@verbose=opts.include?(:verbose)?opts[:verbose]:trueendend编写Verb
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
我遵循了教程http://gettingstartedwithchef.com/,第1章。我的运行list是"run_list":["recipe[apt]","recipe[phpap]"]我的phpapRecipe默认Recipeinclude_recipe"apache2"include_recipe"build-essential"include_recipe"openssl"include_recipe"mysql::client"include_recipe"mysql::server"include_recipe"php"include_recipe"php::modul
我在用Ruby执行简单任务时遇到了一件奇怪的事情。我只想用每个方法迭代字母表,但迭代在执行中先进行:alfawit=("a".."z")puts"That'sanalphabet:\n\n#{alfawit.each{|litera|putslitera}}"这段代码的结果是:(缩写)abc⋮xyzThat'sanalphabet:a..z知道为什么它会这样工作或者我做错了什么吗?提前致谢。 最佳答案 因为您的each调用被插入到在固定字符串之前执行的字符串文字中。此外,each返回一个Enumerable,实际上您甚至打印它。试试
我一直致力于让我们的Rails2.3.8应用程序在JRuby下正确运行。一切正常,直到我启用config.threadsafe!以实现JRuby提供的并发性。这导致lib/中的模块和类不再自动加载。使用config.threadsafe!启用:$rubyscript/runner-eproduction'pSim::Sim200Provisioner'/Users/amchale/.rvm/gems/jruby-1.5.1@web-services/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in`co
给定一个复杂的对象层次结构,幸运的是它不包含循环引用,我如何实现支持各种格式的序列化?我不是来讨论实际实现的。相反,我正在寻找可能会派上用场的设计模式提示。更准确地说:我正在使用Ruby,我想解析XML和JSON数据以构建复杂的对象层次结构。此外,应该可以将该层次结构序列化为JSON、XML和可能的HTML。我可以为此使用Builder模式吗?在任何提到的情况下,我都有某种结构化数据-无论是在内存中还是文本中-我想用它来构建其他东西。我认为将序列化逻辑与实际业务逻辑分开会很好,这样我以后就可以轻松支持多种XML格式。 最佳答案 我最
状态:我正在构建一个应用程序,其中需要一个可供用户选择颜色的字段,该字段将包含RGB颜色代码字符串。我已经测试了一个看起来很漂亮但效果不佳的。它是“挑剔的颜色”,并托管在此存储库中:https://github.com/Astorsoft/picky-color.在这里我打开一个关于它的一些问题的问题。问题:请建议我在Rails3应用程序中使用一些颜色选择器。 最佳答案 也许页面上的列表jQueryUIDevelopment:ColorPicker为您提供开箱即用的产品。原因是jQuery现在包含在Rails3应用程序中,因此使用基