我正在使用 primeng 的下拉指令来允许用户为进入日历应用程序的事件选择约会类型。下拉菜单的向下箭头显示,当单击它时,用户可以正常从列表中选择项目,但下拉菜单应显示所选项目的地方没有显示区域。我可以验证选择一个项目是否有效,然后单击一个事件,然后单击下拉箭头将显示所选的正确项目。下面是我的组件的 ts、html 和 css 文件。
appointment-detail.component.ts:
import { Input, Component, Output, EventEmitter } from '@angular/core';
import { Event } from '../../shared'
import { Calendar, Button, Dropdown, SelectItem } from 'primeng/primeng'
@Component({
moduleId: module.id,
selector: 'appointment-detail',
templateUrl: 'appointment-detail.component.html',
styleUrls: ['appointment-detail.component.css'],
directives: [Calendar, Button, Dropdown]
})
export class AppointmentDetailComponent {
@Input() event;
@Output() submitDetails: EventEmitter<any> = new EventEmitter();
appointmentTypes: SelectItem[];
constructor() {
this.event = new Event();
this.appointmentTypes = [];
this.appointmentTypes.push({label: 'Select type:', value: ''})
this.appointmentTypes.push({label: 'Meeting', value: 'Meeting'})
this.appointmentTypes.push({label: 'Vacation', value: 'Vacation'})
this.appointmentTypes.push({label: 'Other', value: 'Other'})
}
saveEvent() {
this.submitDetails.emit({action: 'save', event: this.event});
}
deleteEvent() {
this.submitDetails.emit({action: 'delete', event: this.event});
}
}
appointment-detail.component.html:
<div class="modal-content" *ngIf="!event">Loading...</div>
<div class="modal-content" *ngIf="event">
<h2 class="header"> Appointment Details </h2>
<div class="ui-grid ui-grid-responsive ui-fluid">
<div class="ui-grid-row">
<div class="ui-grid-col-2"></div>
<div class="ui-grid-col-2"><label for="vin">Title</label></div>
<input class="ui-grid-col-6" pInputText id="title" [(ngModel)]="event.title" />
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-2"></div>
<div class="ui-grid-col-2"><label for="start">Start</label></div>
<div class="ui-grid-col-6">
<p-calendar id="start" dateFormat="yy-mm-dd" [(ngModel)]="event.start"></p-calendar>
</div>
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-2"></div>
<div class="ui-grid-col-2"><label for="end">End</label></div>
<div class="ui-grid-col-6">
<p-calendar id="end" dateFormat="yy-mm-dd" [(ngModel)]="event.end" placeholder="Optional"></p-calendar>
</div>
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-2"></div>
<div class="ui-grid-col-2"><label for="location">Location</label></div>
<input class="ui-grid-col-6" id="location" [(ngModel)]="event.location" />
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-2"></div>
<div class="ui-grid-col-2"><label for="type">Type</label></div>
<p-dropdown class="ui-grid-col-6" id="type" [options]="appointmentTypes" [(ngModel)]="event.type"></p-dropdown>
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-2"></div>
<div class="ui-grid-col-2"><label for="details">Details</label></div>
<input class="ui-grid-col-6" pInputText id="details" [(ngModel)]="event.details" />
</div>
</div>
<footer>
<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<span class="footer-padding"></span>
<button class="footer-button" type="button" pButton icon="fa-check" (click)="saveEvent()" label="Save"></button>
<button class="footer-button" type="button" pButton icon="fa-close" (click)="deleteEvent()" label="Delete"></button>
<span class="footer-padding"></span>
</div>
</footer>
</div>
appointment-detail.component.css:
.header {
text-align: center;
margin: 15px;
}
.ui-grid-row {
margin-bottom: 4px;
margin-top: 4px;
}
.ui-dialog-buttonpane {
padding: 3px;
display: flex;
}
.footer-padding {
flex: 4;
}
.footer-button {
flex: 2;
}
最佳答案
你的错误在这一行:
this.appointmentTypes.push({label: 'Select type:', value: ''})
如果要显示下拉选择的值,默认选项的值必须为空:
this.appointmentTypes.push({label: 'Select type:', value: null})
关于html - Primeng p-dropdown 指令不显示所选值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38110207/
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我主要使用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
在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这
所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.
我正在学习http://ruby.railstutorial.org/chapters/static-pages上的RubyonRails教程并遇到以下错误StaticPagesHomepageshouldhavethecontent'SampleApp'Failure/Error:page.shouldhave_content('SampleApp')Capybara::ElementNotFound:Unabletofindxpath"/html"#(eval):2:in`text'#./spec/requests/static_pages_spec.rb:7:in`(root)'
目前,Itembelongs_toCompany和has_manyItemVariants。我正在尝试使用嵌套的fields_for通过Item表单添加ItemVariant字段,但是使用:item_variants不显示该表单。只有当我使用单数时才会显示。我检查了我的关联,它们似乎是正确的,这可能与嵌套在公司下的项目有关,还是我遗漏了其他东西?提前致谢。注意:下面的代码片段中省略了不相关的代码。编辑:不知道这是否相关,但我正在使用CanCan进行身份验证。routes.rbresources:companiesdoresources:itemsenditem.rbclassItemi